Ejemplo n.º 1
0
 @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();
 }
Ejemplo n.º 2
0
 @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";
 }