实例:
spring-shiro.xml 1
2
3 /admin/repairType/index = roles["ROLE_ADMIN"]
/admin/user=roles["ROLE_ADMIN"]
/admin/complaint/list= roles["ROLE_SERVICE,ROLE_ADMIN"] jsp页面: 1
2
3
4
5
6
7
8
9 <shiro:hasRole name="ROLE_ADMIN">
<li class="user"><a href="${ctx}/admin/user">用户</a></li>
</shiro:hasRole>
<shiro:hasAnyRoles name="ROLE_ADMIN,ROLE_SERVICE">
<li class="complaint"><a href="${ctx}/admin/complaint/list">服务</a></li>
</shiro:hasAnyRoles>
<shiro:hasRole name="ROLE_ADMIN">
<li class="system"><a href="${ctx}/admin/repairType/index">系统设置</a></li>
</shiro:hasRole>   
在使用Shiro标签库前,首先需要在JSP引入shiro标签: 1 <%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>   
1、介绍Shiro的标签guest标签 :验证当前用户是否为“访客”,即未认证(包含未记住)的用户。 1
2
3
4
5 <shiro:guest> Hi there! Please <a href="login.jsp">Login</a> or <a href="signup.jsp">Signup</a> today! </shiro:guest>   
2、user标签 :认证通过或已记住的用户。 1
2
3
4
5 <shiro:user> Welcome back John! Not John? Click <a href="login.jsp">here<a> to login. </shiro:user>   
3、authenticated标签 :已认证通过的用户。不包含已记住的用户,这是与user标签的区别所在。 1
2
3
4
5 <shiro:authenticated> <a href="updateAccount.jsp">Update your contact information</a>. </shiro:authenticated>   
4、notAuthenticated标签 :未认证通过用户,与authenticated标签相对应。与guest标签的区别是,该标签包含已记住用户。 1
2
3
4
5 <shiro:notAuthenticated> Please <a href="login.jsp">login</a> in order to update your credit card information. </shiro:notAuthenticated>   
5、principal 标签 :输出当前用户信息,通常为登录帐号信息。 1 Hello, <shiro:principal/>, how are you today?   
6、hasRole标签 :验证当前用户是否属于该角色。 1
2
3
4
5 <shiro:hasRole name="administrator"> <a href="admin.jsp">Administer the system</a> </shiro:hasRole>   
7、lacksRole标签 :与hasRole标签逻辑相反,当用户不属于该角色时验证通过。 1
2
3
4
5 <shiro:lacksRole name="administrator"> Sorry, you are not allowed to administer the system. </shiro:lacksRole>   
8、hasAnyRole标签 :验证当前用户是否属于以下任意一个角色。 1
2
3
4
5 <shiro:hasAnyRoles name="developer, project manager, administrator"> You are either a developer, project manager, or administrator. </shiro:lacksRole>   
9、hasPermission标签 :验证当前用户是否拥有指定权限。 1
2
3
4
5 <shiro:hasPermission name="user:create"> <a href="createUser.jsp">Create a new User</a> </shiro:hasPermission> 10、lacksPermission标签 :与hasPermission标签逻辑相反,当前用户没有制定权限时,验证通过。 1
2
3
4
5 <shiro:hasPermission name="user:create"> <a href="createUser.jsp">Create a new User</a> </shiro:hasPermission>

jsp 用shiro 的判断 是否有菜单查看的权限的更多相关文章

  1. 在JSP使用EL中判断指定元素是否存在于指定集合中

    在JSP使用EL中判断指定元素是否存在于指定集合中 1.问题描述 在JSP页面中使用EL表达式判断一个指定元素是否存在于指定集合中? 2.问题解决 eg:指定集合:collection:{1,2,3, ...

  2. Shiro 安全框架详解二(概念+权限案例实现)

    Shiro 安全框架详解二 总结内容 一.登录认证 二.Shiro 授权 1. 概念 2. 授权流程图 三.基于 ini 的授权认证案例实现 1. 实现原理图 2. 实现代码 2.1 添加 maven ...

  3. Shiro入门之二 --------基于注解方式的权限控制与Ehcache缓存

    一  基于注解方式的权限控制 首先, 在spring配置文件applicationContext.xml中配置自动代理和切面 <!-- 8配置自动代理 -->    <bean cl ...

  4. SpringBoot整合Shiro+MD5+Salt+Redis实现认证和动态权限管理|前后端分离(下)----筑基后期

    写在前面 在上一篇文章<SpringBoot整合Shiro+MD5+Salt+Redis实现认证和动态权限管理(上)----筑基中期>当中,我们初步实现了SpringBoot整合Shiro ...

  5. Tornado 判断用户登录状态和操作权限(装饰器)

    判断是否登录: def authenticated(method): '''''' @functools.wraps(method) def wrapper(self, *args, **kwargs ...

  6. bat 判断 bat 是否是以管理员权限运行,和自动以管理员权限运行

    bat 判断 bat 是否是以管理员权限运行,和自动以管理员权限运行 判断 @echo off net.exe session 1>NUL 2>NUL && ( goto ...

  7. bat代码中判断 bat是否是以管理员权限运行,以及自动以管理员权限运行CMD BAT

    · bat 代码中判断bat是否是以管理员权限运行,以及自动以管理员权限运行CMD BAT 一.判断bat是否是以管理员权限运行 @echo off net.exe session >NUL & ...

  8. 【JSP 标签】选择判断c:choose

    在JSP页面中对 根据一个属性的多个可能的值进行相应的输出 <%@ page language="java" contentType="text/html; cha ...

  9. 转:C#判断ContextMenuStrip右键菜单的来源(从哪个控件弹出来的)

    转载自:http://hi.baidu.com/cookiemulan/item/82df8ff867dd53cc531c26c7 有时候,为了提高性能和节约资源,我们会为多个控件,指定同一个右键弹出 ...

随机推荐

  1. thinkphp5项目--企业单车网站(七)

    thinkphp5项目--企业单车网站(七) 项目地址 fry404006308/BicycleEnterpriseWebsite: Bicycle Enterprise Websitehttps:/ ...

  2. 【基础篇】DatePickerDialog日期控件的基本使用(二) ——分别获取年、月、日、时、分

    项目步骤: 1.在Main.xml布局文件中定义对应的组件,Main.xml内容如下: <?xml version="1.0" encoding="utf-8&qu ...

  3. 目前常见的三种SQL分页方式:

    --top not in方式 select top 条数 * from tablename where Id not in (select top 条数*页数 Id from tablename) - ...

  4. 本地运行github上的vue2.0仿饿了么webapp项目

    在vue刚刚开始流行的时候,大多数人学习大概都见到过这样的一个项目吧,可以作为学习此框架的一个模板了 github源码地址:https://github.com/RegToss/Vue-SPA 课程教 ...

  5. TXT小说朗读正式版

    作者:www.gudianxiaoshuo.com 干净清洁的小说朗读软件,支持 TXT阅读.语音朗诵.点评标注.数据挖掘

  6. 20160227.CCPP体系具体解释(0037天)

    程序片段(01):01.一对一模式.c+02.中介者模式.c+03.广播模式.c 内容概要:事件 ///01.一对一模式.c #include <stdio.h> #include < ...

  7. CentOS6.4安装Docker

    首先,须要安装EPEL仓库 # wget http://mirrors.yun-idc.com/epel/6/i386/epel-release-6-8.noarch.rpm # rpm -ivh e ...

  8. vim 技巧之用宏命令批量处理文件

    今天遇到了一种情况,就是我需要同时修改34个文件中的某些字符串的内容,如果一个个打开需改的话,那也太麻烦了.后来就想着能不能通过vim的宏命令来修改呢?现在就总结下关于宏在文件列表中的应用1.首先,我 ...

  9. 1.Maven之(一)Maven是什么

    转自:https://blog.csdn.net/xhxmister/article/details/79409208 首先,Maven的正确发音是[ˈmevən],而不是“马瘟”以及其他什么瘟.Ma ...

  10. 关于ajax访问express服务器的跨域问题

    在学习es6的时候用promise封装了一个ajax <script type="text/javascript"> function getNews(URL) { l ...