shiro页面使用
来源:互联网 发布:spring boot sql 查询 编辑:程序博客网 时间:2024/06/14 06:25
实例:
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>
阅读全文
0 0
- shiro页面使用
- spring mvc + shiro +thymeleaf 扩展使用shiro tags页面标签
- Shiro jsp页面标签
- shiro中的<shiro:principal />标签的使用
- 如何使用Shiro(快速了解Shiro)
- Shiro 注解的使用
- shiro框架的使用
- 二、使用Shiro注解
- shiro使用总结
- shiro的使用入门
- shiro的简单使用
- [shiro]CustomCredentialsMatcher使用spring
- shiro jsp标签使用
- shiro cache使用
- Shiro简单使用
- shiro 框架使用实例
- Shiro方法/注解使用
- spring+shiro 配置使用
- Nginx服务器的安装
- 物联网应用案例:镇海智慧水务
- Linux环境中echo "hello world!"时出错。
- 【趣发现】形态各异的区块链和云计算
- [源码]Elasticsearch源码6(5.4插件开发)
- shiro页面使用
- java代码分析及分析工具
- Python2.x设置命令执行的超时时间
- 【趣发现】10分钟带你看透区块链和云计算之底层技术三要素
- 数字货币,别被“区块链”外衣迷了眼
- AS引用本地aar文件
- ICO被监管之后,区块链将走向何方?九位区块链专家来解答
- 从数据记录发展看区块链(从零开始学区块 197)
- DS2431 修改网上版本 读写(已测试可用)