shiro页面标签shiro:principal的使用

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

<shiro:principal property="name"/> 相当于((User)Subject.getPrincipals()).getName()
  • <%@ taglib prefix=“shiro” uri=“http://shiro.apache.org/tags” %>
    Shiro提供的JSP/GSP的标签库,这使得我们很容易能够在JSP,JSTL或GSP页面的控制基于Subject的状态的输出

  • <shiro:principal property=“name”/>
    相当于((User)Subject.getPrincipals()).getName()
    》》》 就是在doGetAuthenticationInfo中最后返回的实例对象。SimpleAuthenticationInfo info =
    new SimpleAuthenticationInfo(Object principal, Object
    hashedCredentials, ByteSource credentialsSalt, String realmName);
    principal就是user的对象实例
    》》》 类似于user.getName();
    所以它就是为了获取登录时身份验证的用户名

猜你喜欢

转载自blog.csdn.net/bugle_call/article/details/100010915