使用 Spring Security 时,特别是使用 @notation;在控制器中访问主体的正确方法是什么?可以说以下是我的控制器,但我想在某处访问 secure() 方法中的主体...
@Controller
public class LoginController {
@RequestMapping(value = "/login", method = RequestMethod.GET)
public String login(ModelMap map, @RequestParam(value="fail" , required=false) String fail){
map.addAttribute("title", "Login: AD Credentials");
if(fail != null){
map.addAttribute("error", "Invalid credentials");
}
return("login");
}
@RequestMapping("/secure")
@PreAuthorize("isAuthenticated()")
public String secure(ModelMap map, String principal){
System.out.println(principal);
return("secure");
}
}