在web.xml中注意filter和listener的配置顺序 - guo_yang的博客 - CSDN博客

例如:

<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>
   <filter-name>pagerFilter</filter-name>
   <filter-class>com.bjsxt.oa.web.PagerFilter</filter-class>
</filter>
<filter-mapping>
   <filter-name>pagerFilter</filter-name>
   <url-pattern>/*</url-pattern>
</filter-mapping>

这是我最开始的配置顺序,程序始终出错,就是因为filter的配置顺序的问题

正确的顺序:

<filter>
   <filter-name>pagerFilter</filter-name>
   <filter-class>com.bjsxt.oa.web.PagerFilter</filter-class>
</filter>
<filter-mapping>
   <filter-name>pagerFilter</filter-name>
   <url-pattern>/*</url-pattern>
</filter-mapping>

<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配置在前面,哪个就位于filterchain的前面


Original url: Access
Created at: 2019-09-05 17:59:12
Category: default
Tags: none

请先后发表评论
  • 最新评论
  • 总共0条评论