ResponseBody 어노테이션의 작동원리
1. ResponseBody 어노테이션이 붙은 경우
1. 웹 브라우져에서 해당 주소로 요청이 발생하면 (hello-api) helloController에서
hello객체를 리턴해주게 된다.
@ResponseBody가 붙지않은 경우에는 ViewResolver가 작동하지만
지금은 ResponseBody 어노테이션이 붙어있으니 HttpMessageConverter가 작동하게 된다.
여기서 두가지 메서드가 존재하는데
일반 문자열의 경우에는 StringConverter가 작동하게 되고 ,
JSON의 경우에는 JsonConverter가 작동하게 된다.
'자바의 봄(Spring) > 자바와 스프링 공부하기' 카테고리의 다른 글
스프링 핵심 원리(5/8) - 기본편 컴포넌트 스캔 (0) | 2023.01.26 |
---|---|
[Spring] 김영한 스프링 핵심 원리 (2/8) 강의 정리 (0) | 2023.01.18 |
[JAVA] Servlet에 대해서 (0) | 2022.12.21 |
[JPA] @Transient 어노테이션에 관한 이해 (0) | 2022.12.16 |
[JPA] 임베디드 타입 (0) | 2022.12.10 |
댓글