@RequestMapping("/loginCheck") public void loginCheck( String username, String passwd, HttpServletResponse response, HttpServletRequest request) { String result = "{\"result\":true,\"mess\":\"\",\"to\":\"./\"}"; response.setContentType("application/json"); String rememberme = request.getParameter("rememberme"); boolean isSaved = false; if (rememberme == "true") { isSaved = true; } User user = userManager.CheckUser(username, passwd); if (user == null) { result = "{\"result\":false,\"mess\":\"用户名或密码错误\",\"to\":\"\"}"; } else { ConchCookie cookie = new ConchCookie(response, request); cookie.setCookie("username", user.getRegname(), isSaved); cookie.setCookie("uid", user.getUid(), isSaved); } try { PrintWriter out = response.getWriter(); out.write(result); } catch (IOException e) { e.printStackTrace(); } }
@RequestMapping("/addUser") public String addUser(User user, HttpServletRequest request, HttpServletResponse response) { userManager.addUser(user); ConchCookie cookie = new ConchCookie(response, request); cookie.setCookie("username", user.getRegname()); return "redirect:/"; }
@RequestMapping("/getUser") public String getUser(String uid, HttpServletRequest request) { User user = userManager.getUser(uid); HttpSession session = request.getSession(); session.setAttribute("user", user); return "redirect:/setting.html"; }
@RequestMapping("/checkNick") public void CheckNick(String nick, HttpServletResponse response) { String result = "{\"result\":true,\"mess\":\"\"}"; if (userManager.CheckNick(nick)) { result = "{\"result\":false,\"mess\":\"该用户名已经被注册\"}"; } response.setContentType("application/json"); try { PrintWriter out = response.getWriter(); out.write(result); } catch (IOException e) { e.printStackTrace(); } }
@RequestMapping("/updatePwd") public String updatePwd(String uid, String passwd, HttpServletRequest request) { System.out.println(uid + passwd); userManager.updatePwd(passwd, uid); return "redirect:/"; }
@RequestMapping("/updateUser") public String updateUser(User user, HttpServletRequest request) { userManager.updateUser(user); return "redirect:/"; }