Framework & Platform/Spring

Spring - @ResponseBody 응답 시 한글 인코딩(깨짐) 문제

linuxism 2012. 6. 8. 12:48


the default charset of @ResponseBody is iso-8859-1, how to change to utf8.


@RequestMapping(value = "/path", produces="text/plain;charset=UTF-8")

public @ResponseBody String handlePath() {

    .....

}


produces="text/plain;charset=UTF-8"를 사용하여 응답 페이지에 대한 UTF-8 인코딩이 가능하여 한글 깨짐을 방지 할 수 있음.