1. The @RestController annotation in Spring MVC is nothing but a combination of@Controller and @ResponseBody annotation. .
2. The job of@Controller is to create a Map of model object and find a view but @RestControllersimply return the object and object data is directly written into HTTP response as JSON or XML.
2. The job of@Controller is to create a Map of model object and find a view but @RestControllersimply return the object and object data is directly written into HTTP response as JSON or XML.
@Controller @ResponseBody public class MVCController { .. your logic } @RestController public class RestFulController { .... your logic }
4. The @Controller is a common annotation which is used to mark a class as
Spring MVC Controller while @RestController is a special controller used in
RESTFul web services and the equivalent of @Controller + @ResponseBody.
Comments
Post a Comment