美文网首页
Shiro的常用注解以及jsp中Shiro使用的标签

Shiro的常用注解以及jsp中Shiro使用的标签

作者: 我是邱邱 | 来源:发表于2018-09-12 21:17 被阅读0次

Shiro的常用注解

@RequiresPermissions :要求当前Subject在执行被注解的方法时具备一个或多个对应的权限。
@RequiresRoles :要求当前Subject在执行被注解的方法时具备所有的角色,否则将抛出AuthorizationException异常。
@RequiresAuthentication:要求在访问或调用被注解的类/实例/方法时,Subject在当前的session中已经被验证。

jsp中Shiro使用的标签

需要在jsp页面中引入标签
<%@ taglib uri="http://shiro.apache.org/tags" prefix="shiro" %>
标签:
<shiro:authenticated> 登录之后
<shiro:notAuthenticated> 不在登录状态时
<shiro:guest> 用户在没有RememberMe时
<shiro:user> 用户在RememberMe时
<shiro:hasAnyRoles name="abc,123" > 在有abc或者123角色时
<shiro:hasRole name="abc"> 拥有角色abc
<shiro:lacksRole name="abc"> 没有角色abc
<shiro:hasPermission name="abc"> 拥有权限资源abc <shiro:lacksPermission name="abc"> 没有abc权限资源
<shiro:principal> 显示用户身份名称
<shiro:principal property="username"/> 显示用户身份中的属性值

相关文章

网友评论

      本文标题:Shiro的常用注解以及jsp中Shiro使用的标签

      本文链接:https://www.haomeiwen.com/subject/ejobgftx.html