`
y806839048
  • 浏览: 1107279 次
  • 性别: Icon_minigender_1
  • 来自: 上海
文章分类
社区版块
存档分类
最新评论

struts2 2.3版本 action不能提交?参数的原因是源码中截取了?后的

阅读更多

 

struts2 2.3版本  action不能提交?参数的原因是源码中截取了?后的

 

 

FormTag--》Form(evaluateClientSideJsEnablement)--》ServletUrlRenderer(renderFormUrl)

 

从继承树看出form继承closingbean,closingbean继承uibean(CTRL+单击)

 

 

 

 

从继承树看出form继承closingbean,closingbean继承uibean

 

 

 

fromtag 调用form构造函数

 

Form extends ClosingUIBean

ClosingUIBean extends UIBean

 

 

ClosingUIBean中:

 

 public boolean start(Writer writer) {

        boolean result = super.start(writer);

        try {

            evaluateParams();

 

            mergeTemplate(writer, buildTemplateName(openTemplate, getDefaultOpenTemplate()));

        } catch (Exception e) {

            LOG.error("Could not open template", e);

        }

 

        return result;

    }

 

 

 

调用uibean中:

evaluateParams{

populateComponentHtmlId

 

}

 

 

uiBean:

populateComponentHtmlId(form);

 

Form:

   @Override

    protected void populateComponentHtmlId(Form form) {

        if (id != null) {

            addParameter("id", escape(id));

        }

 

        // if no id given, it will be tried to generate it from the action attribute

        // by the urlRenderer implementation

        urlRenderer.renderFormUrl(this);

    }

 

 

ServletUrlRenderer:

 

public void renderFormUrl(Form formComponent) {

String namespace = formComponent.determineNamespace(formComponent.namespace, formComponent.getStack(), formComponent.request);

String action;

 

if(formComponent.action != null) {

action = formComponent.findString(formComponent.action);

} else {

// no action supplied? ok, then default to the current request

// (action or general URL)

ActionInvocation ai = (ActionInvocation) formComponent.getStack().getContext().get(

ActionContext.ACTION_INVOCATION);

if (ai != null) {

action = ai.getProxy().getActionName();

namespace = ai.getProxy().getNamespace();

} else {

// hmm, ok, we need to just assume the current URL cut down

String uri = formComponent.request.getRequestURI();

action = uri.substring(uri.lastIndexOf('/'));

}

}

 

        Map actionParams = null;

        if (action != null && action.indexOf("?") > 0) {

            String queryString = action.substring(action.indexOf("?") + 1);

            actionParams = urlHelper.parseQueryString(queryString, false);

            action = action.substring(0, action.indexOf("?"));

        }

 

        ActionMapping nameMapping = actionMapper.getMappingFromActionName(action);

        String actionName = nameMapping.getName();

        String actionMethod = nameMapping.getMethod();

 

final ActionConfig actionConfig = formComponent.configuration.getRuntimeConfiguration().getActionConfig(

namespace, actionName);

if (actionConfig != null) {

 

ActionMapping mapping = new ActionMapping(actionName, namespace, actionMethod, formComponent.parameters);

String result = urlHelper.buildUrl(formComponent.actionMapper.getUriFromActionMapping(mapping),

                    formComponent.request, formComponent.response, actionParams, null, formComponent.includeContext, true);

formComponent.addParameter("action", result);

 

// let's try to get the actual action class and name

// this can be used for getting the list of validators

formComponent.addParameter("actionName", actionName);

try {

Class clazz = formComponent.objectFactory.getClassInstance(actionConfig.getClassName());

formComponent.addParameter("actionClass", clazz);

} catch (ClassNotFoundException e) {

// this is OK, we'll just move on

}

 

formComponent.addParameter("namespace", namespace);

 

// if the name isn't specified, use the action name

if (formComponent.name == null) {

formComponent.addParameter("name", actionName);

}

 

// if the id isn't specified, use the action name

if (formComponent.getId() == null  && actionName!=null ) {

formComponent.addParameter("id", formComponent.escape(actionName));

}

} else if (action != null) {

// Since we can't find an action alias in the configuration, we just

// assume the action attribute supplied is the path to be used as

// the URI this form is submitting to.

 

            // Warn user that the specified namespace/action combo

            // was not found in the configuration.

            if (namespace != null && LOG.isWarnEnabled()) {

              LOG.warn("No configuration found for the specified action: '" + actionName + "' in namespace: '" + namespace + "'. Form action defaulting to 'action' attribute's literal value.");

            }

 

String result = urlHelper.buildUrl(action, formComponent.request, formComponent.response, null, null, formComponent.includeContext, true);

formComponent.addParameter("action", result);

 

// namespace: cut out anything between the start and the last /

int slash = result.lastIndexOf('/');

if (slash != -1) {

formComponent.addParameter("namespace", result.substring(0, slash));

} else {

formComponent.addParameter("namespace", "");

}

 

// name/id: cut out anything between / and . should be the id and

// name

String id = formComponent.getId();

if (id == null) {

slash = result.lastIndexOf('/');

int dot = result.indexOf('.', slash);

if (dot != -1) {

id = result.substring(slash + 1, dot);

} else {

id = result.substring(slash + 1);

}

formComponent.addParameter("id", formComponent.escape(id));

}

}

 

// WW-1284

// evaluate if client-side js is to be enabled. (if validation

// interceptor does allow validation eg. method is not filtered out)

formComponent.evaluateClientSideJsEnablement(actionName, namespace, actionMethod);

}

 

 

  • 大小: 49.8 KB
分享到:
评论

相关推荐

    struts-2.3.15.3源码

    总的来说,Struts 2.3.15.3 源码的学习可以帮助开发者深入理解MVC框架的设计与实现,以及如何在实际项目中有效地运用Struts 2。通过阅读源码,你可以探索其内部工作原理,提高问题排查能力,并了解如何优化和定制...

    struts-2.3.16.3

    标签"struts2"直接指向了我们讨论的核心,即Struts 2框架。Struts 2以其灵活性和可扩展性著称,它允许开发者通过拦截器(Interceptor)机制来定制请求处理流程,同时支持多种视图技术,如JSP、FreeMarker、 Velocity...

    struts-2.3.1.2源码

    和`org.apache.struts2.views.freemarker`等包提供了对这些模板引擎的支持。 7. **依赖注入(DI)**:Struts 2支持依赖注入,允许开发者通过配置文件声明Action类的依赖,框架会在运行时自动注入。这降低了代码的...

    struts-2.3.15.1 源码

    Struts 2.3.15.1 是一个流行的开源Java Web框架的版本,它基于MVC(Model-View-Controller)设计模式,用于构建高效、可扩展且易于维护的企业级应用程序。该框架由Apache软件基金会开发并维护,是Struts 1的升级版,...

    Struts2的DTD配置文件struts-2.3.dtd

    4. **interceptors**:拦截器是Struts2中实现业务逻辑和控制逻辑分离的重要组件,它可以预处理或后处理Action的调用。开发者可以通过`<interceptor>`和`<interceptor-ref>`来定义和引用拦截器。 5. **default-...

    struts-2.3.16.3 源码开发/调试

    在标签"struts-2.3"中,"2.3"表示Struts2的主版本号,这表明了使用的是Struts2的较新版本,通常会包含一些新特性、改进和安全修复。对于"源码"和"开发调试",意味着这个版本特别适合进行源代码级别的学习和问题排查...

    struts-2.3.1.2-all.zip Struts源码和帮助文档

    开发者可以通过实现`com.opensymphony.xwork2.Action`接口或继承`org.apache.struts2.dispatcher.ng.ExecuteOperations`和`org.apache.struts2.dispatcher.ng.InitOperations`来创建自定义Action。Result则是Action...

    Struts2.3.1.2源码

    Struts2.3.1.2源码是Java Web开发框架Struts2的一个特定版本,主要专注于提供MVC(Model-View-Controller)架构来构建动态Web应用。这个版本的源码提供了深入理解Struts2内部工作原理的机会,对开发者来说是宝贵的...

    struts-2.1.8.1源码和struts-2.3.15.1源码

    1. 更强的安全性:针对之前版本的安全漏洞进行了修复,例如Struts Shiro漏洞和Struts2 S2-045漏洞。 2. Action配置的改进:支持注解方式配置Action,使得配置文件更加简洁。 3. 插件扩展性增强:增加了更多内置插件...

    struts-2.3.16.1-all

    Struts 2是Java Web开发中的一个开源框架,主要用于构建MVC(模型-视图-控制器)架构的应用程序。此“struts-2.3.16.1-all”压缩包包含了Struts 2框架的完整开发包,适用于开发者进行项目开发和学习。 **Struts 2...

    struts-2.3.16.3源码

    这些类通常继承自 `org.apache.struts2.dispatcher.ng.ExecuteOperations` 或实现 `com.opensymphony.xwork2.Action` 接口。 3. **配置文件**:Struts 2 使用 XML 配置文件(如 `struts.xml`)来定义动作映射,关联...

    struts-2.3.15.1-lib.zip官方jar包

    官方发布的"struts-2.3.15.1-lib.zip"是一个包含Struts2框架2.3.15.1版本库文件的压缩包,它包含了所有必要的jar包,以帮助开发者更新他们的系统以抵御已知的安全威胁。此版本的发布是为了修复之前版本中的安全漏洞...

    Struts2.3.15.1版本升级到2.3.32详细流程

    通过上述步骤,您可以有效地将Struts2从2.3.15.1版本升级到2.3.32版本,从而避免了S2-045和S2-046等已知的安全漏洞带来的威胁。此外,定期关注并及时更新所使用的开源库版本,对于保障系统的安全稳定运行至关重要。

    struts-2.3.1.2

    1. **Action和Result**:在Struts 2中,业务逻辑主要由Action类实现,每个Action对应一个用户请求。Action处理完请求后,通过Result来决定如何展示响应。Result可以是重定向、转发到一个页面,或者渲染一个模板。 2...

    Struts2 struts-2.3.16.1版本下的demo

    纯Struts2 struts-2.3.16.1版本下的demo,1、Struts2标签 2、Action 3、ActionSupport中validate 4、prepare 5、modeldriven 6、国际化 7、Token 8、拦截器

    struts-2.3.15.1-all.zip

    Struts 2是Java开发企业级Web应用的一个著名框架,其2.3.15.1版本是一个重要的发行版。这个"struts-2.3.15.1-all.zip"压缩包包含了Struts 2框架的完整组件,是开发者进行Struts 2应用开发的基础。下面将详细阐述...

    Struts2.2 升级到Struts2.3

    例如,Struts2著名的Ognl注入漏洞(CVE-2017-5638),在新版本中应该得到了解决。检查并应用相关的安全配置,以防止类似问题的发生。 4. **新特性与API变更**:Struts2.3可能引入了一些新特性,如增强的插件支持、...

    struts 2.3.15.2 源码

    在Struts 2.3.15.2的源码中,我们可以深入研究以下几个核心知识点: 1. **Action与Result**:Struts 2的核心是Action类,它是业务逻辑的载体。Action类处理HTTP请求,执行相应的业务逻辑,并通过Result返回相应的...

    struts-2.3.14.3

    标题提到的"struts-2.3.14.3"是Struts 2框架的一个特定版本,该版本修复了一个重要的安全漏洞,体现了软件维护和更新的重要性,尤其是对于处理用户输入数据的Web应用程序。 Struts 2框架的核心功能包括动作调度、...

Global site tag (gtag.js) - Google Analytics