======================================
스프링 3.1 이하
====================================== 
- 리턴을 ResponseEntity 타입으로 함
- 헤더에 캐릭터셋을 설정해서 보냄
@RequestMapping("/ajax")
@ResponseBody
public ResponseEntity handleAJAX() {
    
    ....로직....
    HttpHeaders responseHeaders = new HttpHeaders();
    responseHeaders.add("Content-Type", "text/html; charset=utf-8");
    return new ResponseEntity("한글", responseHeaders, HttpStatus.CREATED);
}
======================================
스프링 3.2 이상
======================================
- @RequestMapping의 produces 옵션이 생겨 좀 더 쉽게 적용 가능함
@RequestMapping(value = "/ajax", produces = "application/json; charset=utf8")
public String handleAJAX() {
    
    ....로직....
    
    return "한글"
}
출처 :
http://softline21c.blogspot.kr/2012/06/springmvc-responsebody.html
http://novafactory.net/archives/3126
댓글 없음:
댓글 쓰기