2013-12-16 57 views
2

請幫我查看爲什麼得到這個異常?引起:沒有爲名爲'success'的結果指定結果類型,也許父包沒有指定結果類型?

<struts> 
    <package name="default" extends="struts-default"> 
     <action name="HelloWorld" class="leo.struts.HelloWorldAction"> 
      <result name="success">/success.jsp</result> 
     </action> 
     <action name="bar" class="leo.struts.HelloWorldAction"> 
      <result name="success" >/bar1.jsp</result> 
     </action> 
    </package> 

    <package name="mypackage1" namespace="/"> 
     <action name="moo" class="leo.struts.HelloWorldAction"> 
      <result name="success" >/moo.jsp</result> 
     </action> 
    </package> 

</struts> 

例外:

SEVERE: Exception starting filter struts2 
Error building results for action moo in namespace/- action - file:/D:/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/Strut2Examples/WEB-INF/classes/struts.xml:16:58 
    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: No result type specified for result named 'success', perhaps the parent package does not specify the result type? - result - file:/D:/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/Strut2Examples/WEB-INF/classes/struts.xml:17:28 
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.buildResults(XmlConfigurationProvider.java:575) 
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addAction(XmlConfigurationProvider.java:338) 
    ... 26 more 

回答

3

Struts2的結果類型在包struts-default這是在芯罐子定義。在您的配置中,您應該至少擴展struts-default一個父包。你創建的第二個包不符合規則。

<package name="mypackage1" namespace="/" extends="default"> 

應該解決這個問題。