Exemplo n.º 1
0
 @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();
   }
 }
Exemplo n.º 2
0
 @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:/";
 }
Exemplo n.º 3
0
 @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";
 }
Exemplo n.º 4
0
 @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();
   }
 }
Exemplo n.º 5
0
 @RequestMapping("/updatePwd")
 public String updatePwd(String uid, String passwd, HttpServletRequest request) {
   System.out.println(uid + passwd);
   userManager.updatePwd(passwd, uid);
   return "redirect:/";
 }
Exemplo n.º 6
0
 @RequestMapping("/updateUser")
 public String updateUser(User user, HttpServletRequest request) {
   userManager.updateUser(user);
   return "redirect:/";
 }