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