/index.html为受保护用户):
UserDetails userDetails = (UserDetails)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
要首先检查用户是否已登录,请检查当前用户
Authentication不是
AnonymousAuthenticationToken。
Authentication auth = SecurityContextHolder.getContext().getAuthentication();if (!(auth instanceof AnonymousAuthenticationToken)) { // userDetails = auth.getPrincipal()}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)