request.setAttribute("error", "用户或密码不正确!");
return "/background/framework/login";
}
Authentication authentication = myAuthenticationManager
.authenticate(new UsernamePasswordAuthenticationToken(username,password));
SecurityContext securityContext = SecurityContextHolder.getContext();
securityContext.setAuthentication(authentication);
HttpSession session = request.getSession(true);
session.setAttribute("SPRING_SECURITY_CONTEXT", securityContext);
// 当验证都通过后,把用户信息放在session里
request.getSession().setAttribute("userSession", users);
// 记录登录信息