博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Shiro标签
阅读量:7220 次
发布时间:2019-06-29

本文共 1668 字,大约阅读时间需要 5 分钟。

在使用Shiro标签库前,首先需要在JSP引入shiro标签:

<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
  

1、介绍Shiro的标签guest标签 :验证当前用户是否为“访客”,即未认证(包含未记住)的用户。

<shiro:guest> 
Hi there! Please <a href="login.jsp">Login</a> or <a href="signup.jsp">Signup</a> today! 
</shiro:guest>
  

2、user标签 :认证通过或已记住的用户。

<shiro:user> 
Welcome back John! Not John? Click <a href="login.jsp">here<a> to login. 
</shiro:user>
  

3、authenticated标签 :已认证通过的用户。不包含已记住的用户,这是与user标签的区别所在。

<shiro:authenticated> 
<a href="updateAccount.jsp">Update your contact information</a>. 
</shiro:authenticated>
  

4、notAuthenticated标签 :未认证通过用户,与authenticated标签相对应。与guest标签的区别是,该标签包含已记住用户。

<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标签 :验证当前用户是否属于该角色。

<shiro:hasRole name="administrator"> 
<a href="admin.jsp">Administer the system</a> 
</shiro:hasRole>
  

7、lacksRole标签 :与hasRole标签逻辑相反,当用户不属于该角色时验证通过。

<shiro:lacksRole name="administrator"> 
Sorry, you are not allowed to administer the system. 
</shiro:lacksRole>
  

8、hasAnyRole标签 :验证当前用户是否属于以下任意一个角色。

<shiro:hasAnyRoles name="developer, project manager, administrator"> 
You are either a developer, project manager, or administrator. 
</shiro:lacksRole>
  

9、hasPermission标签 :验证当前用户是否拥有指定权限。

<shiro:hasPermission name="user:create"> 
<a href="createUser.jsp">Create a new User</a> 
</shiro:hasPermission>

10、lacksPermission标签 :与hasPermission标签逻辑相反,当前用户没有制定权限时,验证通过。

<shiro:hasPermission name="user:create"> 
<a href="createUser.jsp">Create a new User</a> 
</shiro:hasPermission>

来源: 

转载地址:http://crqym.baihongyu.com/

你可能感兴趣的文章
Linux中用户和组中认证库和解析库的文件格式以及默认参数定义文件
查看>>
Windows中如何删除大量文件夹
查看>>
radio多次点击 选中与不选中
查看>>
21天让你成为Horizon View高手—Day19:Horizon View 5.2新功能—Html Ac
查看>>
netty初步认知
查看>>
redis
查看>>
用过的发送邮件的方法。
查看>>
VMWare
查看>>
web.xml 中的listener、 filter、servlet 加载顺序及其详解
查看>>
try catch finally
查看>>
Windows编程之作业篇
查看>>
一文了解“Service Mesh(服务网格)”的历史与现在
查看>>
使用 rt_tables 巧妙配置 Linux centos7多网卡多路由实现策略路由
查看>>
Javascript中的RegExp类型
查看>>
Java 基础
查看>>
Spring的代理选择
查看>>
PHP搭建简易留言板
查看>>
websphere set jndi
查看>>
ORACLE同义词总结
查看>>
浅谈教你如何掌握Linux系统
查看>>