返回 Null :
Factory<SecurityManager> factory = new IniSecurityManagerFactory("classpath:shiro.ini");
SecurityManager securityManager = factory.getInstance();
SecurityUtils.setSecurityManager(securityManager);
Subject currentUser = SecurityUtils.getSubject();
System.out.println(currentUser.getPrincipal());
总是它返回null,我错过了什么?
领域是:org.apache.shiro.realm.jdbc.JdbcRealm
答案 0 :(得分:1)
校长为null
,因为您没有登录用户。请查看Subject.isAuthenticated()
或Subject.login()