关于Shiro的标签应用

2018-07-25  本文已影响0人  没事遛弯

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:guest>
  </shiro:guest>
  用户没有身份验证时显示相应信息,即游客访问信息。
  <shiro:user>  
  </shiro:user>
  用户已经身份验证/记住我登录后显示相应的信息。
  <shiro:authenticated>  
  </shiro:authenticated>
  用户已经身份验证通过,即Subject.login登录成功,不是记住我登录的。
  <shiro:notAuthenticated>  
  </shiro:notAuthenticated>
  用户已经身份验证通过,即没有调用Subject.login进行登录,包括记住我自动登录的也属于未进行身份验证。
  <shiro: principal/>  
  <shiro:principal property="username"/>
  相当于((User)Subject.getPrincipals()).getUsername()。
  <shiro:lacksPermission name="org:create"> 
  </shiro:lacksPermission>
  如果当前Subject没有权限将显示body体内容。
  <shiro:hasRole name="admin">  
  </shiro:hasRole>
  如果当前Subject有角色将显示body体内容。
  <shiro:hasAnyRoles name="admin,user">   
  </shiro:hasAnyRoles>
  如果当前Subject有任意一个角色(或的关系)将显示body体内容。
  <shiro:lacksRole name="abc">  
  </shiro:lacksRole>
  如果当前Subject没有角色将显示body体内容。
  <shiro:hasPermission name="user:create">  
  </shiro:hasPermission>
  如果当前Subject有权限将显示body体内容
上一篇 下一篇

猜你喜欢

热点阅读