首页 > 代码库 > struts2中错误There is no Action mapped for namespace [/] and action name [] associated with context path
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] 2 at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:185) 3 at org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63) 4 at org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:37) 5 at com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58) 6 at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:554) 7 at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:81) 8 at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99) 9 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) 10 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) 11 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218) 12 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) 13 at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505) 14 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169) 15 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) 16 at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956) 17 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) 18 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:442) 19 at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1083) 20 at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:640) 21 at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316) 22 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 23 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 24 at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) 25 at java.lang.Thread.run(Thread.java:745)
Struts问题确实让我很烦啊,调好了这个bug,出现下面这个bug,这个有事刚刚弄了一下午的问题。
查找了许多答案,
大致的解决方法如下
1:注意Struts.xml文件的位置,必须在src目录之下
2:
1 <!DOCTYPE struts PUBLIC 2 "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" 3 "http://struts.apache.org/dtds/struts-2.3.dtd">
这里面的Struts—2.3.dtd必须与自己的tomcat版本相一致。
3:
1 <struts> 2 <constant name="struts.devMode" value="http://www.mamicode.com/true" /> 3 <package name="exercise" extends="struts-default" namespace="/" >
在struts文件中开发模式必须默认为true
最后发现虽然我的struts.xml文件位于src文件之下,但是
struts.xm位于src下是为了编译后能找到struts配置文件,必须确保其在WEB-INF之下
更改eclipse web 项目默认编译输出路径:
eclipse中只能针对项目更改,因为其默认的是build目录下的,只能以项目更改:
项目右键 -》properties -》Java Build Path -》source -》Default output folder,选择你的路径,ok!
struts2中错误There is no Action mapped for namespace [/] and action name [] associated with context path
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。