@RequestMapping(value = "/save", method = RequestMethod.POST) public ModelAndView save(@Valid Ferias ferias, BindingResult bindingResult) { if (bindingResult.hasErrors()) { return form(ferias); } feriasRepository.save(ferias); return new ModelAndView("redirect:/ferias/novo-ferias"); }
@RequestMapping(method = RequestMethod.POST, value = "/form-update/{id}") public ModelAndView update( @PathVariable("id") Integer id, @Valid Ferias ferias, BindingResult bindingResult) { ferias.setId(id); if (bindingResult.hasErrors()) { return new ModelAndView("ferias/form-update"); } feriasRepository.save(ferias); return new ModelAndView("redirect:/ferias/list"); }