实例:
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. Java定时器TimeTask

    package com.alan.timer; import java.util.Calendar;import java.util.Date;import java.util.Timer;impor ...

  2. 智课雅思词汇---六、fer是什么意思

    智课雅思词汇---六.fer是什么意思 一.总结 一句话总结:词根:fer = to carry(拿), to bring(带来), to bear(负担, 1.equ是什么意思? 词根:-equ- ...

  3. swing导出html到excel

    swing导出html到excel 1  ShowCopDetal package com.product; import java.awt.BorderLayout; import java.awt ...

  4. 推荐的JavaScript编码规范

    http://www.qdfuns.com/notes/26812/7825414125719306fa409c709ee7b2a3.html

  5. 笔记本E450机械硬盘数据迁移到固态硬盘

    背景: E450机械硬盘使用速度过慢,但E450只有一个SATA位,无法直接使用 “分区助手”迁移. 处理: 1.将固态硬盘通过USB口外接在笔记本上 2.正常打开E450,进入桌面 3.对固态硬盘进 ...

  6. Python环境搭建—安利Python小白的Python安装详细教程

    人生苦短,我用Python.众所周知,Python目前越来越火,学习Python的小伙伴也越来越多.最近看到群里的小伙伴经常碰到不会安装Python或者不知道去哪下载Python安装包等系列问题,为了 ...

  7. centos inotify-rsync配置

    安装 yum -y install inotify-tools yum install rsync innotify说明 inotify介绍-- 是一种强大的.细颗粒的.异步的文件系统监控机制,*&a ...

  8. cz.msebera.android.httpclient.conn.ConnectTimeoutException: Connect to /192.168.23.1:8080 timed out(Android访问后台一直说链接超时)

    明明之前还是可以运行的练习,过段时间却运行不了,一直说访问后台超时, 对于这个问题我整整弄了两天加一个晚上,心酸...,上网找了很多但是都解决不了,我就差没有砸电脑了. 首先 : 第一步:Androi ...

  9. P2186 小Z的栈函数

    P2186 小Z的栈函数 题目描述 小Z最近发现了一个神奇的机器,这个机器的所有操作都是通过维护一个栈来完成的,它支持如下11个操作: NUM X:栈顶放入X. POP:抛弃栈顶元素. INV:将栈顶 ...

  10. python创建多层目录的方式

    将 os.mkdir 改成 os.makedirs(opDir) 哈.