Java 具有相同 url 映射的多个过滤器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19999406/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Multiple filters with same url mapping
提问by mosaad
Is it possible to use two filters that have the same url-mapping?
是否可以使用两个具有相同 url-mapping 的过滤器?
<filter>
<filter-name>TeeFilter</filter-name>
<filter-class>filter1r</filter-class>
</filter>
<filter-mapping>
<filter-name>TeeFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<display-name>CredentialsFilter</display-name>
<filter-name>CredentialsFilter</filter-name>
<filter-class>filter2</filter-class>
</filter>
<filter-mapping>
<filter-name>CredentialsFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
采纳答案by Suresh Atta
Yes. You can.
是的。你可以。
The order you placed in web.xml will execute.
您在 web.xml 中放置的订单将执行。
So here,
所以在这里,
First control goes to TeeFilterand then to CredentialsFilter.
首先控制转到TeeFilter,然后转到CredentialsFilter。
And if you want to execute CredentialsFilterfirst, change the order in web.xml
如果你想先执行 CredentialsFilter,改变web.xml中的顺序

