开发者

Can we confgure filters only for a subset of servlets

开发者 https://www.devze.com 2023-04-07 10:11 出处:网络
I have various different categories of servlets. Can I configure the filters in my web.xml such that each filter only applies for one of the categories of 开发者_如何学Pythonservlet.You can map them o

I have various different categories of servlets. Can I configure the filters in my web.xml such that each filter only applies for one of the categories of 开发者_如何学Pythonservlet.


You can map them on <servlet-name> instead of <url-pattern>.

<filter-mapping>
    <filter-name>yourFilterName</filter-name>
    <servlet-name>yourServlet1Name</servlet-name>
    <servlet-name>yourServlet2Name</servlet-name>
    <servlet-name>yourServlet3Name</servlet-name>
</filter-mapping>

The <servlet-name> must exactly match the same value as in <servlet> definition. This way the filter will be invoked whenever either of those servlets are to be invoked.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号