struts2标签出错:The Struts dispatcher cannot be found...[unknown location]

我在使用struts2标签(<s:debug></s:debug>)时报以下错误:
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]
原因:在index.jsp中我直接使用了struts2标签。在访问应用程序的时候直接访问index.jsp(并未经过action的转发);而在web.xml配置文件中配置struts2的默认拦截器拦截后缀名为.action的应用。

<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>

在这种情况下,struts2的拦截器不起作用。所以报错了。
解决方法:
方法1:修改web.xml对struts2默认拦截器的配置为

<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping></web-app>

方法2:添加一个action,通过这个action转发访问index.jsp
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值