diff --git a/src/main/java/org/springframework/samples/petclinic/owner/OwnerController.java b/src/main/java/org/springframework/samples/petclinic/owner/OwnerController.java index 9d470b1ff56..71f76496933 100644 --- a/src/main/java/org/springframework/samples/petclinic/owner/OwnerController.java +++ b/src/main/java/org/springframework/samples/petclinic/owner/OwnerController.java @@ -26,8 +26,10 @@ import org.springframework.ui.Model; import org.springframework.validation.BindingResult; import org.springframework.web.bind.WebDataBinder; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.InitBinder; import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.servlet.ModelAndView; @@ -55,14 +57,14 @@ public void setAllowedFields(WebDataBinder dataBinder) { dataBinder.setDisallowedFields("id"); } - @RequestMapping(value = "/owners/new", method = RequestMethod.GET) + @GetMapping(value = "/owners/new") public String initCreationForm(Map model) { Owner owner = new Owner(); model.put("owner", owner); return VIEWS_OWNER_CREATE_OR_UPDATE_FORM; } - @RequestMapping(value = "/owners/new", method = RequestMethod.POST) + @PostMapping(value = "/owners/new") public String processCreationForm(@Valid Owner owner, BindingResult result) { if (result.hasErrors()) { return VIEWS_OWNER_CREATE_OR_UPDATE_FORM; @@ -72,13 +74,13 @@ public String processCreationForm(@Valid Owner owner, BindingResult result) { } } - @RequestMapping(value = "/owners/find", method = RequestMethod.GET) + @GetMapping(value = "/owners/find") public String initFindForm(Map model) { model.put("owner", new Owner()); return "owners/findOwners"; } - @RequestMapping(value = "/owners", method = RequestMethod.GET) + @GetMapping(value = "/owners") public String processFindForm(Owner owner, BindingResult result, Map model) { // allow parameterless GET request for /owners to return all records @@ -104,14 +106,14 @@ public String processFindForm(Owner owner, BindingResult result, Map model) { return "pets/createOrUpdateVisitForm"; } // Spring MVC calls method loadPetWithVisit(...) before processNewVisitForm is called - @RequestMapping(value = "/owners/{ownerId}/pets/{petId}/visits/new", method = RequestMethod.POST) + @PostMapping(value = "/owners/{ownerId}/pets/{petId}/visits/new") public String processNewVisitForm(@Valid Visit visit, BindingResult result) { if (result.hasErrors()) { return "pets/createOrUpdateVisitForm";