Add UTF-8 encoding to ResponseEntity
responseHeaders.add("Content-Type", "text/html; charset=utf-8");
The solution was to add a StringHttpMessageConverter
with utf-8
in restTemplate
bean like:
@Bean
public RestTemplate restTemplate() {
RestTemplate restTemplate = new RestTemplate();
restTemplate.getMessageConverters()
.add(0, new StringHttpMessageConverter(Charset.forName("UTF-8")));
return restTemplate;
}
I've solved the same problem just adding charset=utf8 to my RequestMapping.
Before
@RequestMapping(path = "/{id}", method = RequestMethod.GET, produces = "application/hal+json")
After
@RequestMapping(path = "/{id}", method = RequestMethod.GET, produces = "application/hal+json;charset=utf8")
I add this to my other methods too. I hope this helps.