mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-21 07:15:49 +00:00
Fix processCreationForm and processUpdateForm in OwnerController Fixes #1544
This commit is contained in:
parent
d8fcd11e67
commit
8c65704c78
1 changed files with 4 additions and 4 deletions
|
@ -71,9 +71,9 @@ class OwnerController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/owners/new")
|
@PostMapping("/owners/new")
|
||||||
public String processCreationForm(@Valid Owner owner, BindingResult result, RedirectAttributes redirectAttributes) {
|
public String processCreationForm(@Valid Owner owner, BindingResult result, RedirectAttributes redirectAttributes, Model model) {
|
||||||
if (result.hasErrors()) {
|
if (result.hasErrors()) {
|
||||||
redirectAttributes.addFlashAttribute("error", "There was an error in creating the owner.");
|
model.addAttribute("owner", owner);
|
||||||
return VIEWS_OWNER_CREATE_OR_UPDATE_FORM;
|
return VIEWS_OWNER_CREATE_OR_UPDATE_FORM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,9 +137,9 @@ class OwnerController {
|
||||||
|
|
||||||
@PostMapping("/owners/{ownerId}/edit")
|
@PostMapping("/owners/{ownerId}/edit")
|
||||||
public String processUpdateOwnerForm(@Valid Owner owner, BindingResult result, @PathVariable("ownerId") int ownerId,
|
public String processUpdateOwnerForm(@Valid Owner owner, BindingResult result, @PathVariable("ownerId") int ownerId,
|
||||||
RedirectAttributes redirectAttributes) {
|
RedirectAttributes redirectAttributes,Model model) {
|
||||||
if (result.hasErrors()) {
|
if (result.hasErrors()) {
|
||||||
redirectAttributes.addFlashAttribute("error", "There was an error in updating the owner.");
|
model.addAttribute("owner", owner);
|
||||||
return VIEWS_OWNER_CREATE_OR_UPDATE_FORM;
|
return VIEWS_OWNER_CREATE_OR_UPDATE_FORM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue