Spring Security中当已登录用户再次访问登录界面时,应跳转到home

@RequestMapping("/login")
  public String login(){
    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    if(auth instanceof AnonymousAuthenticationToken){
      return "login";
    }else{
      return "home";
    }
}

 

你可能感兴趣的:(秒扒Spring)