开发者

Exclude filter from certain url's

开发者 https://www.devze.com 2022-12-13 06:45 出处:网络
I\'m using a filter in web.xml to check if a user is logged in or not: <filter> <filter-name>LoginFilter</filter-name>

I'm using a filter in web.xml to check if a user is logged in or not:

<filter>
    <filter-name>LoginFilter</filter-name>
    <filter-class>com.mycompany.LoginFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>LoginFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

And this works like a charm until I have a stylesheet or image I want to exclude from this filter. I know one approach is to put every开发者_如何学Cthing that's protected inside /privateor similar, and then set the url-pattern to: <url-pattern>/private/*</url-pattern>. The downside to this is my URLs now looking like: http://www.mycompany.com/private/mypage instead of http://www.mycompany.com/mypage. Is there another solution to this problem, that let me keep my pretty-urls?


One solution should be the SpringSecurity (was Acegi Security) approach: make your url-pattern includes everything and exclude undesidered patterns in your filter body.

0

精彩评论

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