@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"; } }
@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; }
@RequestMapping("/add") // 处理add模块所有请求 private String add(User user) { userService.signup(user); return "default"; }