From 2bf1accdc34b8638c3631ec7570a8b5b4b26b7a5 Mon Sep 17 00:00:00 2001 From: Rafael da Silva Santos <62489286+Skan90@users.noreply.github.com> Date: Sun, 9 Oct 2022 07:52:12 -0300 Subject: [PATCH] APPLICATION_JSON_UTF8_VALUE is Deprecated From Documentation: "APPLICATION_JSON_UTF8_VALUE Deprecated. as of 5.2 in favor of APPLICATION_JSON_VALUE since major browsers like Chrome now comply with the specification and interpret correctly UTF-8 special characters without requiring a charset=UTF-8 parameter" https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/http/MediaType.html --- .../samples/petclinic/rest/PetRestController.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/springframework/samples/petclinic/rest/PetRestController.java b/src/main/java/org/springframework/samples/petclinic/rest/PetRestController.java index 6759cdcf..24cafa95 100644 --- a/src/main/java/org/springframework/samples/petclinic/rest/PetRestController.java +++ b/src/main/java/org/springframework/samples/petclinic/rest/PetRestController.java @@ -51,7 +51,7 @@ public class PetRestController { @Autowired private ClinicService clinicService; - @RequestMapping(value = "/{petId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + @RequestMapping(value = "/{petId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Pet> getPet(@PathVariable("petId") int petId){ Pet pet = this.clinicService.findPetById(petId); if(pet == null){ @@ -60,7 +60,7 @@ public class PetRestController { return new ResponseEntity<Pet>(pet, HttpStatus.OK); } - @RequestMapping(value = "", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + @RequestMapping(value = "", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Collection<Pet>> getPets(){ Collection<Pet> pets = this.clinicService.findAllPets(); if(pets.isEmpty()){ @@ -69,12 +69,12 @@ public class PetRestController { return new ResponseEntity<Collection<Pet>>(pets, HttpStatus.OK); } - @RequestMapping(value = "/pettypes", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + @RequestMapping(value = "/pettypes", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Collection<PetType>> getPetTypes(){ return new ResponseEntity<Collection<PetType>>(this.clinicService.findPetTypes(), HttpStatus.OK); } - @RequestMapping(value = "", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + @RequestMapping(value = "", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Pet> addPet(@RequestBody @Valid Pet pet, BindingResult bindingResult, UriComponentsBuilder ucBuilder){ BindingErrorsResponse errors = new BindingErrorsResponse(); HttpHeaders headers = new HttpHeaders(); @@ -88,7 +88,7 @@ public class PetRestController { return new ResponseEntity<Pet>(pet, headers, HttpStatus.CREATED); } - @RequestMapping(value = "/{petId}", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + @RequestMapping(value = "/{petId}", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Pet> updatePet(@PathVariable("petId") int petId, @RequestBody @Valid Pet pet, BindingResult bindingResult){ BindingErrorsResponse errors = new BindingErrorsResponse(); HttpHeaders headers = new HttpHeaders(); @@ -109,7 +109,7 @@ public class PetRestController { return new ResponseEntity<Pet>(currentPet, HttpStatus.NO_CONTENT); } - @RequestMapping(value = "/{petId}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + @RequestMapping(value = "/{petId}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE) @Transactional public ResponseEntity<Void> deletePet(@PathVariable("petId") int petId){ Pet pet = this.clinicService.findPetById(petId); -- GitLab