ssm框架整合时遇到的问题

这是我在整合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>

推荐使用第三个方式!!!
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值