警告: No configuration found for the specified action: 'login.action' in namespace: '/'. Form action defaulting to 'action' attribute's literal value.
struts.xml文件配置如下:
<package name="default" namespace="/" extends="struts-default">
<action name="login" class="com.rjkf.userlogin.action.LoginAction">
<result name="success">/success.jsp
</result>
<result name="error">/error.jsp
</result>
</action>
</package>
jsp页面如下:
<h1>用户登陆</h1>
<s:form name="Login" action="login.action" method="post" namespace="/">
<s:textfield name="username" label="用户名"></s:textfield><br>
<s:password name="password" label="密码"></s:password><br>
<s:submit name="submit" value="登陆"></s:submit>
</s:form>
在网上找了很多资料没有解决,原来是
struts2的标签<s:form 会自动添加.action 我们不用手动添加
所以我们将
<s:form name="Login" action="login.action" method="post" namespace="/">
改为
<s:form name="Login" action="login" method="post" namespace="/">
就OK了
如果不是用struts标签则需手动添加.action