[英]Exclude filter from certain url's
我在web.xml中使用過濾器來檢查用戶是否登錄:
<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>
這就像一個魅力,直到我有一個樣式表或圖像,我想從這個過濾器中排除。 我知道一種方法是將所有受保護的內部/private
或類似,然后將url-pattern設置為: <url-pattern>/private/*</url-pattern>
。 這方面的缺點是我的URL現在看起來像: http://www.mycompany.com/private/mypage
: http://www.mycompany.com/private/mypage
而不是http://www.mycompany.com/mypage
。 是否有另一個解決這個問題的方法,讓我保留我的漂亮網址?
一個解決方案應該是SpringSecurity(是Acegi Security)方法:使您的url-pattern包含所有內容並排除過濾器主體中未考慮的模式。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.