5.Spring security从当前请求对象中获取登陆用户

@RequestMapping("getUser")

public void getUser(HttpServletRequest req){

  String remoteUser=req.getRemoteUser();

  Authentication auth=(Authentication) req.getUserPrincipal();

  System.out.println("remoteUser:"+remoteUser);

  System.out.println("auth.getName():"+auth.getName());

}

posted @ 2022-06-16 10:48  JavaShop  阅读(145)  评论(0编辑  收藏  举报