<s:form action="XX.action"> 与 <s:form action="XX"> 的区别
============= struts.xml
<package name="home" extends="demo" namespace="/demo/home">
<action name="home" class="com.demo.home.HomeAction">
<result name="login" type="redirect-action">
<param name="namespace">/demo/login</param>
<param name="actionName">login!init.action</param>
</result>
<result name="userManage" type="redirect-action">
<param name="namespace">/demo/userManage</param>
<param name="actionName">userManage!init.action</param>
</result>
</action>
</package>
<package name="userManage" extends="demo" namespace="/demo/userManage">
<action name="userManage" class="com.demo.userManage.UserManageAction">
<result name="login" type="redirect">/login/login.jsp</result>
</action>
</package>
<package name="login" extends="demo" namespace="/demo/login">
<action name="login" class="com.demo.login.LoginAction">
<result name="input">/login/login.jsp</result>
</action>
</package>
===========================login.jsp
<s:form action="
login.action" method="post" namespace="/demo/login">
<table width="100%" align="center">
<tr><td>name : <s:textfield name="loginForm.name"/></td></tr>
<tr><td>password : <s:password name="loginForm.password"/></td></tr>
<tr><td><s:submit name="login" value="submit" method="login"/> </td></tr>
</table>
</s:form>
============ 问题
从home进入login.jsp页面时,点击"submit"按钮,程序执行正常。
但是从userManage重定向到login.jsp页面时,点击"submit"按钮,出现下面的异常:
javax.servlet.ServletException:
java.lang.NoSuchMethodException: com.opensymphony.xwork2.ActionSupport.login()
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:515)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:419)
然后我把login.jsp的 <s:form action="
login.action[color=#FF0000][/color]" method="post" namespace="/demo/login">
改成<s:form action="
login[color=#FF0000][/color]" method="post" namespace="/demo/login">
就能正常执行了。
请问为什么从home进入login.jsp页面时可以正常执行,
而从userManage重定向到login.jsp页面时就不行了?加“.action”和不加“.action”的区别是什么?
多谢!!!
------解决方案--------------------PS:--加“.action”和不加“.action”的区别是什么?
看web.xml就知道拉 web系统最开始找Struts是从这开始
<servlet>
<servlet-name>action</servlet-name>
<!-- 也是一servlet-->
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>3</param-value>
</init-param>
<init-param>