반응형
restTemplate.getMessageConverters().add(0,new StringHttpMessageConverter(Charset.forName("UTF-8")));
final String payload = buildPayload("text", msg).toString();
return restTemplate.postForObject(token, payload, String.class);
Slack Webhook를 사용 시
RestTemplate의 기본 Charset이 ISO-8859-1이기 때문에
한글을 사용해주면 다 깨져서 ?로 나오게 되는데
이걸 방지해주려면 위 코드를 참고해서
Charset을 UTF-8로 변경해주면 되는데
restTemplate명.getMessageConverters().add(0,new StringHttpMessageConverter(Charset.forName("UTF-8")));
변경 후 다시 한글을 넣어 출력해보면
?가 나오지 않고 정상으로 출력된다
반응형
'Tools > etc' 카테고리의 다른 글
Sourcetree commit과 동시에 push하는 방법 (0) | 2022.05.11 |
---|---|
Sourcetree 이전 commit comment 수정방법 (0) | 2022.05.11 |
자바 온라인 컴파일러 사이트 (0) | 2022.05.06 |
크롬 브라우저 캐시 사용 안하는 방법 (0) | 2022.05.06 |
Sourcetree Stash 사용방법 정리 (0) | 2022.05.04 |
댓글