Reputation: 2640
how can i decode UTF-8 in the ResponseEntity (especially when i get Umlauts). I also tried with SpringHttpMessageConverter, but this is not working.
RestTemplate restTemplate = new RestTemplate();
//this is not working only by POST
restTemplate.getMessageConverters().add(0, new StringHttpMessageConverter(Charset.forName("UTF-8")));
ResponseEntity<List<WebUser>> responseEntity = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET,
requestEntity, new ParameterizedTypeReference<List<WebUser>>() {
});
//responseEntity.getBody().get(0).getFirstName() should be Müller but I get Müler
Upvotes: 0
Views: 1051
Reputation: 1235
should be Müller but I get Müler
It's not an UTF-8 issue. ü
is an HTML entity (see here for the list of entities). You should unescape HTML entities in response to get UTF-8 strings that you want (see this answer on how to do that using Apache Commons).
Upvotes: 2