过滤器要经过一个判断,不然他不知道你的请求是否会符合规定,
web.xml里面的过滤器配置只支持以下三种
① 完全匹配
<url-pattern>/test/zhidao.action</url-pattern>
② 目录匹配
<url-pattern>/test/*</url-pattern>
③ 扩展名匹配
<url-pattern>*.action</url-pattern>
看着第三种也符合我们的需求是吧,但是这种的扩展性不好,比如我们现在有一个这样的需求:
1、.do,.action扩展名的都要是struts2的请求,我们使用struts.action.extension,就可以达到,但是只使用web.xml里面的配置很难达到
2、如果我们只使用了3的过滤器的配置,我们现在又有一个需求,我们只需要过滤URL为/action/开头的,而扩展名又是action的,怎么办?这个时候我们使用2的目录匹配,加上struts.action.extension,也可以达到需求了
楼主加点分吧,嘿嘿
追问
你说的我懂,但不是我问的。你再回答下我把分给你
当url-pattern配置为/*时,所有的请求都经过了struts2过滤器,但请求不是sturts配置文件中的访问方式(例如:action为后缀)那么此时struts2过滤器有什么作用, Struts tags are only usable when the request has passed through its servlet filter,i want to know like this. can you tell me another thing about that ?sorry, my computer can't use the Chinese = =!! 3q