@RequestMapping(method = RequestMethod.POST) public String create(@Valid User user, BindingResult result) { if (result.hasErrors()) { return "user/createForm"; } userManager.save(user); return "redirect:/user/" + user.getId(); }
@RequestMapping(value = "{id}", method = RequestMethod.GET) public String getView(@PathVariable Long id, Model model) { User user = userManager.find(id); if (user == null) { throw new ResourceNotFoundException(id); } model.addAttribute(user); return "user/view"; }