shiro+thymeleaf常见问题

shiro+thymeleaf+springboot

org.thymeleaf.exceptions.TemplateProcessingException: 
Error during execution of processor 'at.pollux.thymeleaf.shiro.processor.attribute.HasPermissionAttrProcessor'
java.lang.IllegalArgumentException: 
Wildcard string cannot be null or empty. Make sure permission strings are properly formatted.

翻译为:通配符字符串不能为空或空。确保权限字符串被正确格式化。

问题原因:

<button shiro:hasPermission="blog:bContent:add" type="button" class="btn  btn-primary"  onclick="add()">
        <i class="fa fa-plus" aria-hidden="true"></i>添加
</button>

在页面中设置权限验证, 在授权时,sql语句获取的权限列表中有为空的值 导致报错。

select m.Perms as perms
        from user u join role_menu rm on u.RoleId= rm.RoleId
        join menu m on rm.MenuId =m.MenuId
        where u.UserID=13  and m.Perms !=""

直接不等于空字符串即可,其中 is not null 不能排除为空字符串。


版权声明:本文为qq_56800327原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。