日期:2014-05-17  浏览次数:20832 次

struts2.3配置action报错url
我是eclipse+struts2.3+spring2.0配置环境,
js中代码:
document.forms[0].action = "/testWeb1/login.do?method=execute";
document.forms[0].submit();
struts-config.xml中代码:
<action name="login" class="com.wang.action.TestLogin">
<result name="success">./testpage/success.jsp</result>
</action>
报错:
警告: Unhandled exception
org.apache.struts.chain.commands.InvalidPathException: No action config found for the specified url.
at org.apache.struts.chain.commands.AbstractSelectAction.execute(AbstractSelectAction.java:71)
at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191)
at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:305)
at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191)
at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
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:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
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:861)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)
------解决方案--------------------
引用:
Quote: 引用:

Quote: 引用:

Quote: 引用:

struts2的action默认是".action"结尾的,struts1是".do",要么你改js,要么<action name="login.do" class="com.wang.action.TestLogin">

这个规则是在web.xml中的配置中设置的吧。
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping

大哥你用struts2怎么还能配servlet呢。。。建议你好好补习一下struts基础。。这是最最最基础的基础

用来struts2就不能配置servlet吗?不是这样的吧?

没表达清楚,struts2当然和servlet不冲突,我的意思是根据楼主的疑问,说.action要在web.xml里配,LZ把servlet请求和action请求搞混了,我就是想说这个意思。