@RequestMapping(value = "/create", method = RequestMethod.POST) public String saveNew(@Valid @ModelAttribute Task task, BindingResult result, Model model) { if (result.hasErrors()) { return "todo/edit"; } todoService.saveTask(task); return "redirect:/todo/" + task.getId() + "/edit"; }
@RequestMapping(value = "/{taskId}/edit", method = RequestMethod.POST) public String saveEdit(@Valid @ModelAttribute Task task, BindingResult result, Model model) { todoService.saveTask(task); return "redirect:/todo/" + task.getId() + "/edit"; }