struts2的配置之could not find action or result 问题的解决方法(struts.xml文件路径)

struts2的配置中:could not find action or result 问题的解决方法

以上是我的工程目录结构,我把struts.xml没有放到src下,而是根据自己的习惯放到新目录:web-inf/conf/下了。这时候需要在web.xml中进行必要的配置,配置情况如下:


    struts2
    org.apache.struts2.dispatcher.ng.filter.strutsprepareandexecutefilter
     
     config 
     struts-default.xml,struts-plugin.xml,/web-inf/conf/struts.xml 
     


struts.xml内容如下:



  
    index.jsp
  



这时候在ie地址栏中访问:http://localhost:808/test/ddd

时会报错,错误信息如下:

警告: could not find action or result
there is no action mapped for namespace / and action name ddd. - [unknown location]
at com.opensymphony.xwork2.defaultactionproxy.prepare(defaultactionproxy.java:178)
at org.apache.struts2.impl.strutsactionproxy.prepare(strutsactionproxy.java:61)
at org.apache.struts2.impl.strutsactionproxyfactory.createactionproxy(strutsactionproxyfactory.java:39)
at com.opensymphony.xwork2.defaultactionproxyfactory.createactionproxy(defaultactionproxyfactory.java:47)
at org.apache.struts2.dispatcher.dispatcher.serviceaction(dispatcher.java:478)
at org.apache.struts2.dispatcher.ng.executeoperations.executeaction(executeoperations.java:77)
at org.apache.struts2.dispatcher.ng.filter.strutsprepareandexecutefilter.dofilter(strutsprepareandexecutefilter.java:91)
at org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:235)
at org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:206)
at org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:233)
at org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:191)
at org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:128)
at org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:102)
at org.apache.catalina.core.standardenginevalve.invoke(standardenginevalve.java:109)
at org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:293)
at org.apache.coyote.http11.http11processor.process(http11processor.java:849)
at org.apache.coyote.http11.http11protocol$http11connectionhandler.process(http11protocol.java:583)
at org.apache.tomcat.util.net.jioendpoint$worker.run(jioendpoint.java:454)
at java.lang.thread.run(thread.java:619)
2009-12-9 10:01:44 com.opensymphony.xwork2.util.logging.commons.commonslogger warn
警告: could not find action or result
there is no action mapped for namespace / and action name ddd. - [unknown location]
at com.opensymphony.xwork2.defaultactionproxy.prepare(defaultactionproxy.java:178)
at org.apache.struts2.impl.strutsactionproxy.prepare(strutsactionproxy.java:61)
at org.apache.struts2.impl.strutsactionproxyfactory.createactionproxy(strutsactionproxyfactory.java:39)
at com.opensymphony.xwork2.defaultactionproxyfactory.createactionproxy(defaultactionproxyfactory.java:47)
at org.apache.struts2.dispatcher.dispatcher.serviceaction(dispatcher.java:478)
at org.apache.struts2.dispatcher.ng.executeoperations.executeaction(executeoperations.java:77)
at org.apache.struts2.dispatcher.ng.filter.strutsprepareandexecutefilter.dofilter(strutsprepareandexecutefilter.java:91)
at org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:235)
at org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:206)
at org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:233)
at org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:191)
at org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:128)
at org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:102)
at org.apache.catalina.core.standardenginevalve.invoke(standardenginevalve.java:109)
at org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:293)
at org.apache.coyote.http11.http11processor.process(http11processor.java:849)
at org.apache.coyote.http11.http11protocol$http11connectionhandler.process(http11protocol.java:583)
at org.apache.tomcat.util.net.jioendpoint$worker.run(jioendpoint.java:454)
at java.lang.thread.run(thread.java:619)

————————————————————————————————————————————————————

解决办法如下:

只要对web.xml稍做一点改动就行,改成如下:


    struts2
    org.apache.struts2.dispatcher.ng.filter.strutsprepareandexecutefilter
     
     config 
     struts-default.xml,struts-plugin.xml,../conf/struts.xml 
     


这样就一切ok了。

你可能感兴趣的:(struts2)