spring security3教程系列--页面权限标签问题
来源:互联网 发布:情趣用品商城源码 编辑:程序博客网 时间:2024/05/22 00:48
本文章摘编、转载需要注明来源 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>
这样我们就可以在页面继续使用security的标签
<%@ page language="java" pageEncoding="UTF-8"%><%@ taglib prefix='sec' uri='http://www.springframework.org/security/tags' %><%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <base href="<%=basePath%>"> <title>SPRING SECURITY TEST CENTER</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </head> <body> 用户名:<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> </body></html>
- spring security3教程系列--页面权限标签问题
- Spring Security3 页面 权限标签
- Spring Security3 页面 权限标签
- spring security3教程系列--自定义权限管理
- spring security3教程系列--自定义权限管理
- spring security3教程系列--自定义权限管理
- spring security3教程系列--扩展验证码
- spring security3教程系列--自定义过滤链
- spring security3教程系列--扩展验证码
- Spring Security3权限控制
- spring security3教程系列--如何踢出用户
- spring security3教程系列--如何踢出用户
- spring security3教程系列--如何踢出用户
- Spring Security3.1权限管理
- Spring Security3 - MVC 整合教程
- Spring Security3 - MVC 整合教程
- Spring Security3 - MVC 整合教程
- Spring Security3 - MVC 整合教程
- 国际化标签 GIS
- android自定义控件以及复用控件示例详解
- Java实现序列化
- 与人聊天&聊天问题
- java RMI的含义
- spring security3教程系列--页面权限标签问题
- C primer plus 基础总结(一)
- 如何让java程序最小化至系统托盘
- 超微7046GT+Redhat Enterprise 6.1+CUDA5.0的安装说明
- ubuntu 无线问题解决
- USB2.0和USB3.0的区别
- IOS 项目配置--构建输出DIR
- android 中系统自带的主题与样式
- 优化SQL语句的若干方法 /Oracle学习笔记