日期:2014-05-20  浏览次数:20654 次

求教struts2的配置问题
struts。xml
<struts>
<package name="h" extends="struts-default" namespace="/test">
<action name="hello" class="com.HelloStruts" method="execute">
<result name="hello">/hello.jsp</result>
</action>
</package>
</struts>


web。xml

<filter>
<filter-name>filter</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
<init-param>
<param-name>struts</param-name>
<param-value>
WebRoot/WEB-INF/config/HelloStruts.xml
</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>



为什么出现这个错误
HTTP Status 404 - There is no Action mapped for action name hello.
type Status report

message There is no Action mapped for action name hello.

description The requested resource (There is no Action mapped for action name hello.) is not available.


在线等。。。。急急急!!!!!!!!!!!!!!!!!

------解决方案--------------------
jsp里调用的时候加namespace了么?
感觉自己写工程没必要设namespace
------解决方案--------------------
<package name="h" extends="struts-default" namespace="/test">
把 namespace="/test"去掉,然后<form action="hello.action">

------解决方案--------------------
XML code
<form action="/test/hello.action">

------解决方案--------------------
探讨
jsp里


<form action="test/hello.action">
<input type="submit" value="xxx">
</form>

------解决方案--------------------
探讨

XML code
<form action="/test/hello.action">

------解决方案--------------------
404没用找到路径··提交路径有问题
------解决方案--------------------
<s:form action="hello.action" namespace="test">
</form>这样肯定行的。
------解决方案--------------------
action="<%=request.getContextPath()%>/test/hello.action"
这样看了吗?