spring security权限标签记录
#转:原文链接http://blog.csdn.net/shadowsick/article/details/8868863
当我们自定义了spring security3 的过滤链的时候发现页面权限控制标签<sec:authorize之类的已经不能起效了,这是因为我们缺少一个必须的实例
所以找了下源码看到需要一个DefaultWebInvocationPrivilegeEvaluator决策器实例,直接配置一个实例然后注入FilterSecurityInterceptor的实例即可
<!-- 页面标签权限功能依赖 -->
<bean id="webInvocationFilter"
class="org.springframework.security.web.access.DefaultWebInvocationPrivilegeEvaluator">
<constructor-arg ref="filterSecurityInterceptor" />
</bean>```
用户名:<sec:authentication property="name" />, 欢迎来到主页!<br>
拥有权限:<sec:authentication property="principal.authorities" /><br>
是否可用:<sec:authentication property="principal.enabled" /><br>
未被锁定:<sec:authentication property="principal.accountNonLocked" /><br>
<sec:authorize ifAnyGranted="ROLE_SUPERVISOR">您是超级管理员,可看到该信息:(这里可以用逗号分隔,加入多个角色你拥有管理员权限)</sec:authorize><br>
<sec:authorize url='/test.jsp'>你登陆成功了可以看到: <a href="<%=path %>/supervisor/index.jsp">管理页面</a></sec:authorize>
<br><a href="<%=path %>/logout">注销登录</a>
`