The Struts dispatcher cannot be found.

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] 

在struts2.x中直接访问jsp文件会报上面的错误,原因大概是
(1)JSP页面中没有加入类似下面内容:
<%@ taglib prefix="s" uri="/struts-tags"%>

(2)拦截器不是/*,如下
<filter-mapping>    
    <filter-name>struts2</filter-name>    
    <url-pattern>*.action</url-pattern>  
</filter-mapping>


解决办法:
1、采用 http://ip:port/SayHello.action 访问
2、将过滤器的*.action改为/*,如下
<filter-mapping>    
    <filter-name>struts2</filter-name>    
    <url-pattern>/*</url-pattern>  
</filter-mapping>

3、修改jsp文件,不使用struts标签

猜你喜欢

转载自simplehumn.iteye.com/blog/1069280