The difference and connection between @RestController and @Controller and @ResponseBody

1. @RestController is a collection of @Controller and @ResponseBody annotations in Spring MVC

 

2. The @RestController annotation has been added since Spring 4.0, and its main function is to facilitate the construction of Restful Web services

 

3. @Controller can directly return JSP, html pages. If you need to return entity objects, you need to add @ResponseBody annotation on the method before you can return entity objects

 

4. All methods in the @RestController class can only return String, Object, Json and other entity objects, and cannot jump to the page

 

5. @RestController is equivalent to @ResponseBody+@Controller

 

Guess you like

Origin blog.csdn.net/m0_38116456/article/details/113698098