spring security 获取当前用户

  • controller中,直接参数注入
@RequestMapping
public void execute(Principal principal){}
  • 其他bean中
SecurityContextHolder.getContext().getAuthentication().getPrincipal()

猜你喜欢

转载自blog.csdn.net/zhoudingding/article/details/107205957