728x90
728x90
@RestController
-
[Spring] @RestController / @RequestBodyJAVA/Spring(Springboot) 2021. 8. 1. 18:40
@RestController 에 대해서 알아보자 @Controller 는 반환 값이 'String' 이면 뷰 이름으로 인식된다. 그래서 뷰를 찾고 뷰가 렌더링된다 @RestController 는 반환값으로 뷰를 찾는 것이 아니라 HTTP 메시지 바디에 바로 입력한다. 따라서 실행 결과로 'String' 값을 받을 수 있다 @RequestBody 도 비슷한 역할을 수행한다 @Controller 를 사용하는 경우 return 값으로 String 을 받게 되면 자동적으로 ViewResolver 를 찾게 되는데 @RestController 같이 body 에 메세지를 뿌려주고 싶은 경우 @RequestBody 를 사용하면 된다 @ResponseBody @RequestMapping("/request-param-v2..