spring security 获取当前用户

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

posted on 2022-04-11 22:39  路过君  阅读(115)  评论(0编辑  收藏  举报

导航