我为我的应用程序使用了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