spring security中获取当前登录用户
2022-03-14 本文已影响0人
莫名ypc
spring security中获取当前登录用户
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (!(authentication instanceof AnonymousAuthenticationToken)) {
String currentUserName = authentication.getName();
return currentUserName;
}