第一
种方法:使用扩展包获取用户信息
使用方法
1、首先 引入Thymeleaf和SpringSecurity的扩展依赖:
我的SpringBoot版本是2.2.6.RELEASE
其默认引入的的SpringSecurity版本是5.2.2.RELEASE
因此 我选择5版本的扩展依赖包
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity5</artifactId>
</dependency>
也可根据自己情况选择4的扩展依赖包:thymeleaf-extras-springsecurity4
2、然后 在Thymeleaf页面上引入相关约束:
<html lang