我们在Struts2开发中,我们在参考别人代码的时候很容易迷惑为什么核心分发器有的时候用"FilterDispatcher",而有的时候用"StrutsPrepareAndExecuteFilter"?两者有什么区别?怎么区别怎么配置?为什么这样?
先给出你的答案:当Struts的版本 >= 2.1.3用StrutsPrepareAndExecuteFilter(推荐)
先给出两个web.xml 文件的例子。
1----FilterDispatcher
<
filter
>
< filter-name >struts2 </ filter-name >
< filter-class >
org.apache.struts2.dispatcher.FilterDispatcher
</ filter-class >
</ filter >
< filter-mapping >
< filter-name >struts2 </ filter-name >
< url-pattern >/* </ url-pattern >
</ filter-mapping >
< filter-name >struts2 </ filter-name >
< filter-class >
org.apache.struts2.dispatcher.FilterDispatcher
</ filter-class >
</ filter >
< filter-mapping >
< filter-name >struts2 </ filter-name >
< url-pattern >/* </ url-pattern >
</ filter-mapping >
2----- StrutsPrepareAndExecuteFilter
< 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 >/* </ url-pattern >
</ filter-mapping >
转载请注明链接,谢谢。