@RequestMapping(value = "login.do", method = RequestMethod.POST) public ModelMap login() throws Exception { String username = request.getParameter("username"); String password = request.getParameter("password"); String verifycode = request.getParameter("code"); String sessioncode = (String) session.getAttribute("code"); ModelMap modelmap = new ModelMap(); try { User user = userService.getUserbyusername(username); if (verifycode.equalsIgnoreCase(sessioncode)) { if (user != null && user.getPassword().equals(password)) { modelmap.put("user", user); modelmap.put("code", Code.SUCCESS); session.setAttribute("user", user); logger.info(user.getUsername() + "登录成功"); } else { modelmap.put("code", Code.USERNAMEORPASSWORD_WRONG); } } else { modelmap.put("code", Code.CODE_WRONG); } } catch (Exception e) { e.printStackTrace(); modelmap.put("code", Code.UNKOWN_WRONG); } return modelmap; }
响应的如图所示
qq_那一眸的风情_03788798
_潇潇暮雨
相关分类