@RequestMapping(value = "/login", method = RequestMethod.POST) public String login(String userId, String password, HttpSession session) { try { userService.login(userId, password); session.setAttribute("user", userService.findUser(userId)); } catch (PasswordMismatchException e) { return "user/login"; } return "redirect:/"; }
@RequestMapping(value = "", method = RequestMethod.POST) public String create(User user, Model model) { try { userService.create(user); } catch (ExistedUserException e) { } return "redirect:user"; }
@RequestMapping(value = "", method = RequestMethod.PUT) public String update(User user, Model model) { userService.update(user); return "redirect:user"; }
@RequestMapping("/{userId}/form") public String updateForm(@PathVariable String userId, Model model) { model.addAttribute("user", userService.findUser(userId)); return "user/form"; }
@RequestMapping("") public String index(Model model) { model.addAttribute("users", userService.finds()); return "user/index"; }