在struts2.X中运行项目时发生“HTTP Status 404 - There is no Action mapped for namespace / and action name .”或者“HTTP Status 500 - The Struts dispatcher cannot be found. This is usually caused by using Struts tags without the associated filter. Struts tags are only usable when the request has passed through its servlet filter, which initializes the Struts dispatcher needed for this tag. - [unknown location]”这两个错误时的解决方法:1、我们应将 web.xml 中的<filter-mapping>改为如下:
<filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
注:应将原来url-pattern中的 *.action 改为 /* ,但是如果此时运行项目时 例如:http://localhost:8080/strutsdemo 又发生了 HTTP Status 404 - There is no Action mapped for namespace / and action name . 这个错误,此时应该 直接输入具体要访问的URL,例如 http://localhost:8080/struts/user_input.jsp 就行了也可参考http://www.cnblogs.com/gulvzhe/archive/2011/11/21/2256632.html