Interview questions
Question 79 of 254
FreeWhat is the difference between @Controller and @RestController?
Spring MVC & REST APIs
@Controller is the base Spring MVC stereotype where method return values are typically interpreted as logical view names to be resolved into a rendered template (e.g., Thymeleaf/JSP), unless a method is separately annotated @ResponseBody. @RestController is a convenience meta-annotation combining @Controller and @ResponseBody at the class level, so every method's return value is automatically serialized directly into the HTTP response body (typically as JSON) instead of being resolved as a view.
Beginner3 min

