예제 #1
0
 @RequestMapping("/login")
 private String login(User user) {
   user = userService.login(user);
   if (user != null) {
     getSession().setAttribute("user", user);
     return "index";
   } else {
     getRequest().setAttribute("message", "invalid username or password.");
     return "default";
   }
 }
예제 #2
0
 @RequestMapping("/check")
 private @ResponseBody Map<String, Object> check(@RequestParam String username) {
   User user = userService.queryOne(new User(null, username, null));
   Map<String, Object> map = new HashMap<>();
   if (user != null) {
     map.put("isUsernameExist", true);
   } else {
     map.put("isUsernameExist", false);
   }
   return map;
 }
예제 #3
0
 @RequestMapping("/add") // 处理add模块所有请求
 private String add(User user) {
   userService.signup(user);
   return "default";
 }