jsp 用shiro 的判断 是否有菜单查看的权限
实例:
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 的判断 是否有菜单查看的权限的更多相关文章
- 在JSP使用EL中判断指定元素是否存在于指定集合中
在JSP使用EL中判断指定元素是否存在于指定集合中 1.问题描述 在JSP页面中使用EL表达式判断一个指定元素是否存在于指定集合中? 2.问题解决 eg:指定集合:collection:{1,2,3, ...
- Shiro 安全框架详解二(概念+权限案例实现)
Shiro 安全框架详解二 总结内容 一.登录认证 二.Shiro 授权 1. 概念 2. 授权流程图 三.基于 ini 的授权认证案例实现 1. 实现原理图 2. 实现代码 2.1 添加 maven ...
- Shiro入门之二 --------基于注解方式的权限控制与Ehcache缓存
一 基于注解方式的权限控制 首先, 在spring配置文件applicationContext.xml中配置自动代理和切面 <!-- 8配置自动代理 --> <bean cl ...
- SpringBoot整合Shiro+MD5+Salt+Redis实现认证和动态权限管理|前后端分离(下)----筑基后期
写在前面 在上一篇文章<SpringBoot整合Shiro+MD5+Salt+Redis实现认证和动态权限管理(上)----筑基中期>当中,我们初步实现了SpringBoot整合Shiro ...
- Tornado 判断用户登录状态和操作权限(装饰器)
判断是否登录: def authenticated(method): '''''' @functools.wraps(method) def wrapper(self, *args, **kwargs ...
- bat 判断 bat 是否是以管理员权限运行,和自动以管理员权限运行
bat 判断 bat 是否是以管理员权限运行,和自动以管理员权限运行 判断 @echo off net.exe session 1>NUL 2>NUL && ( goto ...
- bat代码中判断 bat是否是以管理员权限运行,以及自动以管理员权限运行CMD BAT
· bat 代码中判断bat是否是以管理员权限运行,以及自动以管理员权限运行CMD BAT 一.判断bat是否是以管理员权限运行 @echo off net.exe session >NUL & ...
- 【JSP 标签】选择判断c:choose
在JSP页面中对 根据一个属性的多个可能的值进行相应的输出 <%@ page language="java" contentType="text/html; cha ...
- 转:C#判断ContextMenuStrip右键菜单的来源(从哪个控件弹出来的)
转载自:http://hi.baidu.com/cookiemulan/item/82df8ff867dd53cc531c26c7 有时候,为了提高性能和节约资源,我们会为多个控件,指定同一个右键弹出 ...
随机推荐
- Create the Data Access Layer
https://docs.microsoft.com/en-us/aspnet/web-forms/overview/getting-started/getting-started-with-aspn ...
- poj--1637--Sightseeing tour(网络流,最大流判断混合图是否存在欧拉图)
Sightseeing tour Time Limit: 1000MS Memory Limit: 10000KB 64bit IO Format: %I64d & %I64u Sub ...
- BootstrapDialog模态框
5最近是比较烦直接使用Bootstrap里面的模态框,满屏都是模态框代码,看得心烦.然后想起以前使用的BootstrapDialog.show()的方式,挺简单好用的.然后就拿出来分享一下. 1.下载 ...
- BZOJ 1012 单调队列+二分
思路: 维护一个单减的序列 序号是单增的 每回二分查找第一个比询问的大的值 我手懒 用得lower_bound //By SiriusRen #include <cstdio> #incl ...
- PHP写文件到指定位置
<?php $fp = fopen("output.json", "r+"); $flag = fseek($fp, -3, SEEK_END); if( ...
- 在Windows下如何创建指定的虚拟环境
前几天给大家分享了如何在默认的情况下创建虚拟环境,没来得及上车的伙伴,可以戳这篇文章:在Windows下如何创建虚拟环境(默认情况下).今天小编给大家分享一下,如何创建的指定的Python环境. 创建 ...
- ajax的几个面试题
一.什么是AJAX(请谈一下你对Ajax的认识)AJAX是“Asynchronous JavaScript and XML”的缩写.他是指一种创建交互式网页应用的网页开发技术.Ajax包含下列技术:基 ...
- 【Docker端口映射】
Docker端口映射即将容器内开放的端口映射到宿主机端口,以实现外部网络的访问. 首先,我们先下载用于测试端口映射的镜像: [root@fedora ~]# docker pull training/ ...
- shell脚本的if判断语句
if条件判断语句 if (表达式) #if ( Variable in Array ) 语句1 else 语句2 fi 1.测试数字大小 #!/bin/sh NUM=100 if (( $NUM &g ...
- du---是对文件和目录磁盘使用的空间查看
du命令也是查看使用空间的,但是与df命令不同的是Linux du命令是对文件和目录磁盘使用的空间的查看,还是和df命令有一些区别的. 语法 du [选项][文件] 选项 -a或-all 显示目录中个 ...