spring security权限标签记录

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>

`


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值