【问题标题】:There is no result type defined for type 'redirect-action' mapped with name 'success'没有为使用名称“成功”映射的类型“重定向操作”定义结果类型
【发布时间】:2013-02-20 23:41:58
【问题描述】:
<action name="saveGetStarted" class="com.sample.action.GetStartedAction" method="save">
      <interceptor-ref name="defaultStack"/>
      <result name="success" type="redirect-action">
          <param name="actionName">preQualification</param>
          <param name="customerId">${customerId}</param>
      </result>
      <result name="input">/jsp/getStarted.jsp</result>
      <result name="error">/jsp/getStarted.jsp</result>
</action>

<action name="preQualification"  class="com.sample.action.PreQualificationAction">
    <result name="success">/jsp/preQualification.jsp</result>
    <result name="input"  >/jsp/preQualification.jsp</result>
</action>

使用struts2-core-2.0.12.jar 可以正常工作,但更新到struts2-core-2.1.6.jar 后,出现以下错误:

Caused by: There is no result type defined for type 'redirect-action' mapped with name 'success'.  Did you mean 'redirectAction'? - result - file:/D:/eclipse-indigo/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/Fundation/WEB-INF/classes/struts.xml:19:54
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.buildResults(XmlConfigurationProvider.java:613)
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addAction(XmlConfigurationProvider.java:364)
    ... 26 more

是什么导致了错误?

【问题讨论】:

  • 我的想法是阅读错误信息。

标签: java configuration struts2 naming-conventions camelcasing


【解决方案1】:

您正在使用旧的符号表示动作重定向结果。将redirect-action 更改为redirectAction

【讨论】:

    【解决方案2】:

    在 Struts 2.3.x 中,一些代码已更改,例如 redirect-action 更改为 redirectAction

    所以你必须这样声明它-

    <action name="saveGetStarted" class="com.sample.action.GetStartedAction" method="save">
                <interceptor-ref name="defaultStack"/>
                <result name="success" type="redirectAction">
                    <param name="actionName">preQualification</param>
                    <param name="customerId">${customerId}</param>
                </result>
                <result name="input">/jsp/getStarted.jsp</result>
                <result name="error">/jsp/getStarted.jsp</result>
              </action>
    
             <action name="preQualification"  class="com.sample.action.PreQualificationAction"  method="excute">
                    <result name="success">/jsp/preQualification.jsp</result>
                    <result name="input">/jsp/preQualification.jsp</result>
              </action>
    

    【讨论】:

      【解决方案3】:

      自 Struts 2.1.0 以来,所有默认的结果名称拦截器名称都已更改 Letter case,从旧的 spinal-case 更改为新的 camelCase

      来自Struts 2.1.1 release version notes

      与以前版本的向后兼容性问题

      由于2.1.0:所有默认结果名称和拦截器名称现在都采用驼峰命名法
      (例如,以前是redirect-action,现在是redirectAction

      ...

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2014-01-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-08-09
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多