引起:没有为类型链定义结果类型'映射名称'成功'

时间:2013-12-26 17:05:47

标签: java exception configuration struts2

使用Chaining.Exception尝试时出现异常

  

<action name="chain1" class="leo.struts.Chain1Action">

<!-- Chain Result configuration starts -->
    <package name="interceptorpackage">
        <interceptors>
            <interceptor name="chainingintercept1" class="leo.struts.SimpleInterceptor" />
            <interceptor name="chainingintercept2" class="leo.struts.LoggingInterceptor">
                <param name="name">leo</param>
            </interceptor>
            <interceptor name="chainingintercept3" class="leo.struts.ChainInterceptor" />
        </interceptors>
    </package>
    <package name="public" extends="interceptorpackage">
        <action name="chain1" class="leo.struts.Chain1Action">
            <interceptor-ref name="chainingintercept1"/>
            <result type="chain">chain2</result>
        </action>

        <action name="chain2" class="leo.struts.Chain2Action">
            <!-- Chain to another namespace -->
            <interceptor-ref name="chainingintercept2"/>
            <result type="chain">
                <param name="actionName">chain3</param>
                <param name="namespace">/secure</param>
            </result>
        </action>
    </package>

    <package name="secure" extends="interceptorpackage" namespace="/secure">
        <action name="chain3" class="leo.struts.Chain3Action">
                <interceptor-ref name="chainingintercept3"/>
            <result >noresultend.jsp</result>
        </action>
    </package>
    <!-- Chain Result configuration starts -->

例外:

SEVERE: Exception starting filter struts2
Error building results for action chain1 in namespace  - action - file:/D:/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/Strut2Examples/WEB-INF/classes/struts.xml:135:57
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addAction(XmlConfigurationProvider.java:340)
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:429)
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:239)
    at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:111)
    at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reload(DefaultConfiguration.java:152)
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:52)
    at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:395)
    at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:452)
    at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:201)
    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:295)
    at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:422)
    at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:115)
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4072)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4726)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
    at org.apache.catalina.core.StandardService.start(StandardService.java:525)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: There is no result type defined for type 'chain' mapped with name 'success' - result - file:/D:/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/Strut2Examples/WEB-INF/classes/struts.xml:137:25
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.buildResults(XmlConfigurationProvider.java:584)
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addAction(XmlConfigurationProvider.java:338)
    ... 26 more

1 个答案:

答案 0 :(得分:1)

如果在结果配置中定义类型,则应在包配置中定义结果类型的值,或者从超级包继承。结果类型"chain"在您的基础包应继承的包"struts-default"中定义。如果您不想使用默认结果类型,则可以根据DTD定义自己的类型。

<package name="interceptorpackage" extends="struts-default" abstract="true">
  <result-types>
    <result-type name="chain" class="com.opensymphony.xwork2.ActionChainResult"/>
  <result-types>

在此配置中,结果类型"chain"在父包"struts-default"中定义,并在包中重写。要定义足以继承结果类型或定义自己的结果类型的结果类型,可以覆盖它。