struts2中错误There is no Action mapped for namespace [/] and action name [] associated with context path


1 There is no Action mapped for namespace [/] and action name [] associated with context path [/Struts2_0300_Action2]. - [unknown location]
at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:185)
at org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63)
at org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:37)
at com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:554)
at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:81)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:442)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1083)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:640)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)

Struts问题确实让我很烦啊,调好了这个bug,出现下面这个bug,这个有事刚刚弄了一下午的问题。

查找了许多答案,

大致的解决方法如下

1:注意Struts.xml文件的位置,必须在src目录之下

2:

 <!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">

这里面的Struts—2.3.dtd必须与自己的tomcat版本相一致。

3:

 <struts>
<constant name="struts.devMode" value="true" />
<package name="exercise" extends="struts-default" namespace="/" >

在struts文件中开发模式必须默认为true

最后发现虽然我的struts.xml文件位于src文件之下,但是

struts.xm位于src下是为了编译后能找到struts配置文件,必须确保其在WEB-INF之下

更改eclipse web 项目默认编译输出路径:

eclipse中只能针对项目更改,因为其默认的是build目录下的,只能以项目更改: 
项目右键 -》properties -》JavaBuild Path -》source -》Default output folder,选择你的路径,ok!

最后有个方法,如果找不到对应的可以直接在后面加上自己Action的名字

上一篇:c#的if判断与异常处理


下一篇:鹅厂大佬亲授,400集Python课程免费送,要不要是你的事,反正损失不是我的!!