实例:
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. LVDS原理及设计指南

    LVDS是一种低摆幅的差分信号技术,它使得信号能在差分PCB 线对或平衡电缆上以 几百Mbps的速率传输,其低压幅和低电流驱动输出实现了低噪声和低功耗.       IEEE 在两个标准中对LVDS ...

  2. Bundle捆绑压缩技术

    Bundle捆绑压缩技术由命名空间System.Web.Optimization中的类提供.顾名思义,这些类是用来优化Web页面性能的,它们通过压缩文件大小,捆绑文件(把多个文件合成一个下载文件)来实 ...

  3. 定时器函数SetTimer

    原文链接:http://www.cnblogs.com/zhangpengshou/archive/2009/04/05/1429770.html 一.SetTimer表示的是定义个定时器.根据定义指 ...

  4. ZOJ 3175 Number of Containers 分块

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=3216 乱搞的...watashi是分块做的...但我并不知道什么是分块...大 ...

  5. Android 第三方分享中遇到的问题以及解决方案

    本文来自http://blog.csdn.net/liuxian13183/ ,引用必须注明出处! 第三方登录和分享过程中难免遇到各种纠结的问题,下面将我遇到的分享给大家. 先说第三方登录 1.首先要 ...

  6. GPU和CPU的区别

    http://blog.csdn.net/conowen/article/details/7256260 这里有几种计算平台的Flynn分类法 GPU是SIMD 多核CPU是MIMD 硬件结果多核处理 ...

  7. 实战c++中的string系列--string的替换、查找(一些与路径相关的操作)

    今天继续写一些string操作. string给我们提供了非常多的方法,可是每在使用的时候,就要费些周折. 场景1: 得到一个std::string full_path = "D:\prog ...

  8. Android自己定义视图(一):带下划线的TextView

    package com.francis.underlinetextviewtest; import android.content.Context; import android.content.re ...

  9. PHP CLI模式下的多进程应用分析

    PHP在非常多时候不适合做常驻的SHELL进程, 他没有专门的gc例程, 也没有有效的内存管理途径. 所以假设用PHP做常驻SHELL, 你会常常被内存耗尽导致abort而unhappy 并且, 假设 ...

  10. js01----json,数组

    <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content ...