What are the differences between the annotations @Controller and @RestController?
Mostly used traditional Spring MVC service.
Represents RESTful web service in Spring.
It is mostly used in Spring MVC service where model data needs to rendered using view.
It is used in case of RESTful web service that returns object values bound to response body.
If response values need to be converted through HttpMessageConverters and sent via response object, extra annotation @ResponseBody needs to be used on the class or the method handlers.
The default behavior of the @RestController needs to be written on the response body because it is the combination of @Controller and @ResponseBody.
@Controller provides control and flexibility over how the response needs to be sent.
@RestController annotation has no such flexibility and writes all the results to the response body.