User users = this.userDao.querySingleUser(username);
if (users == null || !users.getUserPassword().equals(password)) {
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);