这是我在整合struts2,mybatis,spring时遇到的一些问题,在此分享出来,并记录下来供参考.
第一个问题和解决方式:
The Struts dispatcher cannot be found. This is usually caused by using Struts tags without the associated filter. 异常
异常信息: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.
-----这是由于添加了struts的标签后引起的
在web.xml的配置
<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>*.action</url-pattern>
</filter-mapping>
默认是*.action过滤
引入struts标签后,出现这种异常,归纳以下有三种解决方法:
1:将web.xml下struts过滤器的过滤方式*.action改为/*;这样会默认对所有的进行过滤,自我感觉不是很好.
2:在页面不使用struts标签.
3:再加一个过滤方式
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
推荐使用第三个方式!!!
本文分享了在整合Struts2、MyBatis和Spring框架过程中遇到的一个常见问题及其解决方案。主要介绍了当使用Struts2标签时出现的The Struts dispatcher cannot be found异常,并提供了三种有效的解决方法。
1198

被折叠的 条评论
为什么被折叠?



