我爲我的應用程序使用了spring security。以下是我的applicationContext-Security.xml中的一些行,將訪問權限設置爲ROLE_USER for/offers和/添加鏈接,並且沒有/ list鏈接過濾器。春季安全登錄/註銷url相關問題
<intercept-url pattern="/list*" filters="none" />
<intercept-url pattern="/offers**" access="ROLE_USER" />
<intercept-url pattern="/add/**" access="ROLE_USER" />
我想告訴LOGIN鏈接時未登錄用戶而當系統用戶登錄,然後這個環節應該由註銷取代。 爲此,我嘗試了下面的代碼在我的jsp頁面。
<security:authorize ifNotGranted="ROLE_USER">
<a href="login.jsp">Login</a>
</security:authorize>
<security:authorize ifAnyGranted="ROLE_USER">
Welcome <security:authentication property="principal.username"/>!
| <a href="logout.htm">Logout</a>
</security:authorize>
當我在/ list鏈接時,它顯示「LOGIN」鏈接。 登錄後,如果用戶重定向到/ offers或/ add link,則顯示「Welcome UserName | LOGOUT」,按照要求工作。但問題是,當和重定向到/列表頁用戶登錄,然後還顯示「登錄」 (用戶已登錄)它應該顯示「歡迎用戶名|退出」
幫助我在這種情況下,是什麼我應該怎麼做才能使它工作? 預先感謝您。
哪個版本的spring-security? – Raghuram 2011-02-04 09:29:51
版本是2.0.4 – Sagar 2011-02-04 10:09:44