Shiro提供了一套JSP标签库来实现页面级的授权控制。
在使用Shiro标签库前,首先需要在JSP引入shiro标签:
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %> |
下面一一介绍Shiro的标签:
guest标签
验证当前用户是否为“访客”,即未认证(包含未记住)的用户。
<shiro:guest> Hi there! Please <a href="login.jsp">Login</a> or <a href="signup.jsp">Signup</a> today! </shiro:guest> |
user标签
认证通过或已记住的用户。
<shiro:user> Welcome back John! Not John? Click <a href="login.jsp">here<a> to login. </shiro:user> |
authenticated标签
已认证通过的用户。不包含已记住的用户,这是与user标签的区别所在。
<shiro:authenticated> <a href="updateAccount.jsp">Update your contact information</a>. </shiro:authenticated> |
notAuthenticated标签
未认证通过用户,与authenticated标签相对应。与guest标签的区别是,该标签包含已记住用户。
<shiro:notAuthenticated> Please <a href="login.jsp">login</a> in order to update your credit card information. </shiro:notAuthenticated> |
principal 标签
输出当前用户信息,通常为登录帐号信息。
Hello, <shiro:principal/>, how are you today? |
hasRole标签
验证当前用户是否属于该角色。
<shiro:hasRole name="administrator"> <a href="admin.jsp">Administer the system</a> </shiro:hasRole> |
lacksRole标签
与hasRole标签逻辑相反,当用户不属于该角色时验证通过。
<shiro:lacksRole name="administrator"> Sorry, you are not allowed to administer the system. </shiro:lacksRole> |
hasAnyRole标签
验证当前用户是否属于以下任意一个角色。
<shiro:hasAnyRoles name="developer, project manager, administrator"> You are either a developer, project manager, or administrator. </shiro:lacksRole> |
hasPermission标签
验证当前用户是否拥有指定权限。
<shiro:hasPermission name="user:create"> <a href="createUser.jsp">Create a new User</a> </shiro:hasPermission> |
lacksPermission标签
与hasPermission标签逻辑相反,当前用户没有制定权限时,验证通过。
<shiro:hasPermission name="user:create"> <a href="createUser.jsp">Create a new User</a> </shiro:hasPermission> |
摘自:http://blog.csdn.net/peterwanghao/article/details/8165028
相关推荐
Apache shiro 标签授权,介绍Apache shiro 标签授权的多种形式。
内容涵盖 Shiro 认证、加密、授权、安全标签、安全注解、会话管理、缓存、Rememberme 等 JavaEE 企业级开发的核心技术。视频讲授过程中通过分析源代码使学员知其然更知其所以然。 【课程内容】 第一章 问候 Shiro ...
以Spring Framework为核心容器,Spring MVC为模型视图控制器,Mybatis Plus为数据访问层, Apache Shiro为权限授权层, Redis为分布式缓存,Quartz为分布式集群调度,JSP作为前端页面引擎,采用JSTL标签库封装组件的...
Shiro(Apache Shiro)是一个强大且易于使用的Java安全框架,用于身份验证、授权、加密和会话管理等安全功能。它提供了简单的API和灵活的配置选项,可以方便地集成到现有的Java应用程序中。 Shiro的主要特点包括: ...
以Spring Framework为核心容器,Spring MVC为模型视图控制器,Mybatis Plus为数据访问层, Apache Shiro为权限授权层, Redis为分布式缓存,JSP作为前端页面引擎,采用JSTL标签库封装组件。 项目介绍 Active4j-flow是...
是以Spring Framework为核心容器,Spring MVC为模型视图控制器,Hibernate为数据访问层, Apache Shiro为权限授权层,Ehcahe对常用数据进行缓存,Disruptor作为并发框架,Bootstrap作为前端框架的优秀 开源 系统。...
本教程为授权出品教程 ...内容涵盖 Shiro 认证、加密、授权、安全标签、安全注解、会话管理、缓存、Rememberme 等 JavaEE 企业级开发的核心技术。视频讲授过程中通过分析源代码使学员知其然更知其所以然。
以Spring Framework为核心容器,Spring MVC为模型视图控制器,Mybatis Plus为数据访问层, Apache Shiro为权限授权层, Redis为分布式缓存,Quartz为分布式集群调度,JSP作为前端页面引擎,采用JSTL标签库封装组件的...
授权方式 编程式:通过写if/else 授权代码块完成 注解式:通过在执行的Java方法上放置相应的注解完成 Spring与Shiro整合 在web.xml配置拦截器 在Shiro配置文件上配置在web.xml对应的bean ...
分级授权:支持栏目授权操作(基于Shiro实现) 定时任务:支持定时发文操作 动态验证码:基于Happy-Captcha 快速验证码框架实现 文件存储:支持本地存储和CDN存储 评论支持:内置了Gitalk评论函数,只需设置相关的...
Apache Shiro | 安全框架 | [http://shiro.apache.org/](http://shiro.apache.org/) Spring session | 分布式Session管理 | [http://projects.spring.io/spring-session/]...
J2eeFAST是一个Java EE企业级快速开发平台,基于经典技术组合(Spring Boot、Spring MVC、Apache Shiro、MyBatis-Plus、Freemarker、Bootstrap、AdminLTE)采用经典开发模式,让初学者能够更快的入门并投入到团队...