简体   繁体   中英

filter not working in servlet

My application is served from this URL - http://t4.gav.com/gui

Now I have added a Servlet filter to filter all requests with /gui/* pattern.

<filter>
    <filter-name>AccessCheckFilter</filter-name>
    <filter-class>t4.AccessCheckFilter</filter-class>
</filter>

<filter-mapping>
    <filter-name>AccessCheckFilter</filter-name>
    <url-pattern>/gui/*</url-pattern>
</filter-mapping>

I'm not sure why mistake Im doing. If I just give root "/" its working.

If your application is served at http://t4.gav.com/gui most probably your context path of your application is /gui. Which means, whatever you configure on your Servlet Filter is relative to this context path. This is why / is working.

Based on your configuration the container will filter the requests on URL /gui/gui/*.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM