SecurityContextHolder.getContext().getAuthentication()为null解决方案
SecurityContextHolder.getContext().getAuthentication();为null解决方案SpringSecurity。之前想用SecurityContextHolder.getContext().getAuthentication()这玩意获取登录后的用户名但是一直空指针。换了各种方案,最后发现是这玩意好像不能放在成员变量的位置,要在方法内部使用。好像是因为这个上下文是和线程相关的。修改前:@Api(tags="后台首页")@RestControllerpu
原创
2022-05-18 20:44:58 ·
6667 阅读 ·
0 评论