}
@RequestMapping("/login")
@ResponseBody
public ResponseData login(HttpServletRequest request) {
User user = new User();
String userName = request.getParameter("j_username");
String password = request.getParameter("j_password");
List<User> list =userService.findByProperty("username", userName);
if(list.size() == 0) {
return new ResponseData(false, "UsernameNotFound", "用户【" + userName + "】不存在.");
} else if(!password.equals(list.get(0).getPassword())) {
return new ResponseData(false, "BadCredentials", "密码不正确,请重新输入.");
} else {
user.setUsername("admin");
HttpSession session = request.getSession();
session.setAttribute("__SESSIONKEY__", user);
return ResponseData.SUCCESS_NO_DATA;
}
}