Shiro标签

在使用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://www.cnblogs.com/lvlv/p/5806426.html

来自为知笔记(Wiz)

时间: 2024-08-03 07:01:39

Shiro标签的相关文章

freemarker 集成 sitemesh 装饰html页面 shiro 标签

guest标签:验证当前用户是否为"访客",即未认证(包含未记住)的用户: shiro标签:<shiro:guest></shiro:guest>  : freemark中: <@shiro.guest>  </@shiro.guest> user标签:认证通过或已记住的用户 shiro标签:<shiro:user> </shiro:user>  :freemark中: <@shiro.user> &l

springboot下html的js中使用shiro标签功能

在js中直接使用shiro标签是不行的 比如 下面有个小技巧 原文地址:https://www.cnblogs.com/xiaostudy/p/10995294.html

springboot thymeleaf和shiro标签整合

这里用的是 thymeleaf 2.x版本的 添加依赖 <dependency> <groupId>com.github.theborakompanioni</groupId> <artifactId>thymeleaf-extras-shiro</artifactId> <version>1.2.1</version> </dependency> 在shiro的configuration中配置 @Bean p

使用shiro标签遇到的部分问题的解决思路

最近几天,在shiro进行系统权限控制.在处理JSP页面的时候,遇到几个问题,纠结好几天,终于成功解决这些问题. 1.使用<shiro:principal>的时候,如何得到整个类的信息? 由于之前,在编写Realm的时候,习惯性的把用户登录名放进SimpleAuthenticationInfo类中,进行返回.当然了,使用<shiro:principal>的时候,就只能得到用户的登录名.其实,使用<shiro:principal>,效果和SecurityUtils.get

shiro标签前台应用

//引包 <%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %> <shiro:hasRole name="J009">//name要判断是否有这个权限 <c:if test="${piid!=null&&piid!=''&&modelkey=='bgsmskhg'}"> <butt

shiro jsp 标签

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&quo

拦截404页面时tomcat抛出异常: org.apache.shiro.UnavailableSecurityManagerException

404页面中包含shiro标签,当访问404页面时,抛出异常: 原因:shiro拦截器配置缺少 标红部分,缺少红色部分导致在serverlet在拦截404页面的时候没有经过shiro  从而使shiro标签解析失败引发错误. <filter-mapping>    <filter-name>shiroFilter</filter-name>    <url-pattern>/*</url-pattern> <dispatcher>RE

Web项目Shiro总结及源码(十六)

shiro过虑器 过滤器简称 对应的java类 anon org.apache.shiro.web.filter.authc.AnonymousFilter authc org.apache.shiro.web.filter.authc.FormAuthenticationFilter authcBasic org.apache.shiro.web.filter.authc.BasicHttpAuthenticationFilter perms org.apache.shiro.web.filt

细说shiro之五:在spring框架中集成shiro

官网:https://shiro.apache.org/ 1. 下载在Maven项目中的依赖配置如下: <!-- shiro配置 --> <dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-core</artifactId> <version>${version.shiro}</version> </dependency&g