コード例 #1
0
ファイル: UserController.java プロジェクト: Coding110/Conch
 @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();
   }
 }
コード例 #2
0
ファイル: UserController.java プロジェクト: Coding110/Conch
 @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:/";
 }