web.xml过滤器如何工作?你有两个过滤器映射到所有页面(/ *)并指定顺序吗? [英] How do web.xml filters work? Can you have two filters map to all pages (/*) and specify the order?
问题描述
我想使用Spring Security,它说要将过滤器映射到/ ***。但我已经有一个映射到/ *的过滤器,它是Tuckee URLRewrite过滤器。
I want to use Spring Security, and it says to map the filter to /***. But I already have a filter mapped to /*, which is the Tuckee URLRewrite filter.
是否可以将两个过滤器映射到同一个东西,并且还有一个指定过滤器被调用的顺序的方法?
Is it possible to map two filters to the same thing, and also is there a way to specify the order that the filters get called?
推荐答案
是的,你可以:
调用过滤器的顺序是与servlet的请求URI匹配的过滤器映射声明出现在过滤器列表中的顺序 - 映射元素
The order in which filters are invoked is the order in which filter-mapping declarations that match a request URI for a servlet appear in the list of filter-mapping elements
即它取决于 web.xml中
< filter-mapping>
元素的顺序
i.e. it depends on the order of your <filter-mapping>
elements in the web.xml
这篇关于web.xml过滤器如何工作?你有两个过滤器映射到所有页面(/ *)并指定顺序吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!