0
我在项目上使用Spring MVC和Spring Security,并且正在使用它实现登录表单。我遇到了一种奇怪的行为,我不会期望,我想知道是否有办法避免它。Spring Security AuthenticationException持久性?
当有登录表单上的身份验证错误,我有一个方法在我的控制器来处理它:
@RequestMapping(value="/failed", method = RequestMethod.GET)
public String showLoginFailurePage(Model model, HttpServletRequest request) {
String authExClass = "";
AuthenticationException authEx = (AuthenticationException) request.getSession().getAttribute(WebAttributes.AUTHENTICATION_EXCEPTION);
if (authEx != null) {
authExClass = authEx.getClass().getSimpleName();
}
model.addAttribute("authExClass", authExClass);
return LOGIN_PAGE;
}
这个工程开始,允许在发生认证错误我显示错误。但是,如果我刷新页面,我期望AuthenticationException不再附加到会话,因此我不会向用户显示错误。但是,似乎这个例外在刷新之后仍然存在。我有一个不正确的假设吗?我应该不以这种方式使用我的请求对象吗?
谢谢! idbentley