programming/Spring

[Spring] RestTemplate 한글 깨짐

LeeBorn 2022. 2. 26. 16:02
반응형

Spring

Spring의 RestTemplate을 이용해서 API를 호출할 때, 한글이 제대로 등록이 안될 때가 있다.

그럴 땐 아래와 같이 인코딩을 설정해서 해결해 볼 수 있다.

RestTemplate restTemplate = new RestTemplate();
restTemplate.getMessageConverters()
        .add(0, new StringHttpMessageConverter(StandardCharsets.UTF_8));

 

** 출처

https://stackoverflow.com/questions/29392422/how-can-i-tell-resttemplate-to-post-with-utf-8-encoding

 

How can I tell RestTemplate to POST with UTF-8 encoding?

I'm having problems posting JSON with UTF-8 encoding using RestTemplate. Default encoding for JSON is UTF-8 so the media type shouldn't even contain the charset. I have tried to put charset in the

stackoverflow.com

반응형