ShiroWildcard string cannot be null or empty. Make sure permission strings are properly formatted

Posted The Gao

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ShiroWildcard string cannot be null or empty. Make sure permission strings are properly formatted相关的知识,希望对你有一定的参考价值。

SpringBoot集成Shiro时,给User对象添加权限,如果user.getPerms()为空,需要跳过,而不能通过info.addStringPermission()方法添加进去。

这里可以通过一个if判断完成。

Subject currentUser = SecurityUtils.getSubject();
User user = (User) currentUser.getPrincipal();
if (user.getPerms() != null) 
    info.addStringPermission(user.getPerms());

以上是关于ShiroWildcard string cannot be null or empty. Make sure permission strings are properly formatted的主要内容,如果未能解决你的问题,请参考以下文章