Strust2中There is no Action mapped for namespace
①login.jsp如下<body><formaction="login.action">用户:<inputtype="text"name="username"><p>密...
①login.jsp如下
<body>
<form action="login.action">
用户:<input type="text" name="username"><p>
密码:<input type="password" name="password"><p>
<input type="submit" value="登入">
</form>
</body>
②strust.xml如下
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<package name="strust2" extends="struts-default">
<action name="login" class="com/strust2/action/LoginAction">
<result name="success">/login_success.jsp</result>
<result name="error">/login_error.jsp</result>
</action>
</package>
</struts>
③web.xml如下
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_9" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Struts Blank</display-name>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
运行时报出There is no Action mapped for namespace [/] and action name [login] associated with context path [/Strust2]哪位高手指点一下,不胜感激啊 展开
<body>
<form action="login.action">
用户:<input type="text" name="username"><p>
密码:<input type="password" name="password"><p>
<input type="submit" value="登入">
</form>
</body>
②strust.xml如下
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<package name="strust2" extends="struts-default">
<action name="login" class="com/strust2/action/LoginAction">
<result name="success">/login_success.jsp</result>
<result name="error">/login_error.jsp</result>
</action>
</package>
</struts>
③web.xml如下
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_9" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Struts Blank</display-name>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
运行时报出There is no Action mapped for namespace [/] and action name [login] associated with context path [/Strust2]哪位高手指点一下,不胜感激啊 展开
2个回答
展开全部
<package name="strust2" namespace="/" extends="struts-default">
<action name="login.action" class="com/strust2/action/LoginAction">
<form action="/login.action">
namespace决定了action的访问路径,默认为"",可以接收所有路径的action
namespace可以写为/,或者/xxx,或者/xxx/yyy,对应的action访问路径为/index.action,
/xxx/index.action,或者/xxx/yyy/index.action.<br/>
namespace最好也用模块来进行命名
<action name="login.action" class="com/strust2/action/LoginAction">
<form action="/login.action">
namespace决定了action的访问路径,默认为"",可以接收所有路径的action
namespace可以写为/,或者/xxx,或者/xxx/yyy,对应的action访问路径为/index.action,
/xxx/index.action,或者/xxx/yyy/index.action.<br/>
namespace最好也用模块来进行命名
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询