问题:导入thymeleaf-extras-springsecurity5后,前台获取不到角色。
org.thymeleaf.extras thymeleaf-extras-springsecurity53.0.4.RELEASE
分析:thymeleaf-extras-springsecurity4和thymeleaf-extras-springsecurity5,存在版本问题,所以导入的命名空间也有区别。
解决:依赖版本为:thymeleaf-extras-springsecurity5时,命名空间应该为:
xmlns:sec="http://www.thymeleaf.org/extras/spring-security"
在获取角色时:应该用
而不是:
如果仍要用:thymeleaf-extras-springsecurity4版本
解决办法:降级springboot版本,2.0.9和2.0.7较为稳定。因为版本降级,所以项目其他位置的导入过的包也需要根据提示修改。
org.springframework.boot spring-boot-starter-parent2.0.9.RELEASE
命名空间导入:
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4
此时获取角色:



