Servlet中过滤器的执行顺序是什么样子的呢?
下文讲述Servlet过滤器的运行顺序,如下所示
Servlet过滤器的运行顺序: 根据web.xml中配置filter-mapping元素的顺序 决定Servlet中过滤器的加载顺序 ----------------------------------------- 例: 下面示例中的Filter加载顺序为: 首先加载Filter2,然后再加载Filter1例: Filter1,Filter2两个过滤器
<filter> <filter-name>Filter1</filter-name> <filter-class>com.java265.test.Filter1</filter-class> <init-param> <param-name>param1</param-name> <param-value>value1</param-value> </init-param> </filter> <filter> <filter-name>Filter2</filter-name> <filter-class>com.java265.test.Filter2</filter-class> <init-param> <param-name>param2</param-name> <param-value>value2</param-value> </init-param> </filter> <filter-mapping> <filter-name>Filter2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <filter-mapping> <filter-name>Filter1</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
版权声明
本文仅代表作者观点,不代表本站立场。
本文系作者授权发表,未经许可,不得转载。