- HttpMessageConverter: Spring MVC 에서 요청과 응답의 데이터 형식을 변환하는 인터페이스
- Json Data를 Http Message Body에서 직접 읽거나 쓸 수 있다.
- HTTP 요청 본문을 객체로 변경하거나, 객체를 HTTP 응답 본문으로 변경할 수 있다.
- ByteArrayHttpMessageConverter
- byte 배열 data를 처리
- MediaType : * / * (전체)
- 반환 : octet-stream
- StringHttpMessageConverter
- String data를 처리
- MediaType : * / *
- 반환 : text/plain
- MappingJackson2HttpMessageConverter
- Json Data를 처리한다.
- 대상 : Object를 가장 많이 사용, Hashmap
- MediaType : application/json
- 반환 : application/json
// 요청 헤더 content-type: application/json @PostMapping("/json") // Data -> produces = "application/json" public Data json(@RequestBody Data data) { log.info("json logic"); return data; }
더보기
참고 사이트 :
HttpMessageConverter (Spring Frameword 6.2.1 API)
HttpMessageConverter (Spring Framework 6.2.1 API)
Read an object of the given type from the given input message, and returns it.
docs.spring.io
Spring Frameword Documentation :: Spring Framework
Spring Framework Documentation :: Spring Framework
Rod Johnson, Juergen Hoeller, Keith Donald, Colin Sampaleanu, Rob Harrop, Thomas Risberg, Alef Arendsen, Darren Davison, Dmitriy Kopylenko, Mark Pollack, Thierry Templier, Erwin Vervaet, Portia Tung, Ben Hale, Adrian Colyer, John Lewis, Costin Leau, Mark F
docs.spring.io
'내일배움캠프 > TIL' 카테고리의 다른 글
[Spring_4기 본캠프] Spring 심화 - Java Exception | Day 55 (1) | 2025.01.03 |
---|---|
[Spring_4기 본캠프] Spring 심화 - 일정관리 앱 개선하기, 리팩토링 | Day 53 (0) | 2024.12.31 |
[Spring_4기 본캠프] 프로젝트 주간 - 프로젝트 발표와 피드백 정리 | Day 51 (0) | 2024.12.28 |
[Spring_4기 본캠프] 프로젝트 주간 - KPT 회고 | Day 50 (0) | 2024.12.26 |
[Spring_4기 본캠프] 프로젝트 주간 - 트러블 슈팅 2 | Day 49 (0) | 2024.12.24 |