@Controller와 @RestController 차이점


@Controller와 @RestController 차이점

스프링에서 컨트롤러를 지정해 주기 위한 어노테이션은 @Controller, @RestController가 있다. 둘을 쉽게 생각하면 @RestController == @Controller + @ResponseBody이다. @Controller 전통적인 Spring MVC의 컨트롤러 어노테이션인 @Controller는 주로 View를 반환하기 위해 사용된다. 1. 클라이언트는 URL형식으로 요청을 보낸다. 2. DispatcherServlet이 요청을 위임할 Handler Mapping을 찾는다. 3. Handler Mapping을 통해 요청을 Controller로 위임한다. 4. Controller는 요청을 처리한 후 View Name을 Handler Adapter한테 반환한다. 5. Handler Ad..


원문링크 : @Controller와 @RestController 차이점