The method in the Controller class in Java project development returns a page or a string solution

1. When the Controller class has a controller that returns the page, you cannot use @RestController to annotate the Controller class.
2. When you need to return the page and the string at the same time, you need to use @Controller to annotate the Controller class, and then use @ResponseBody to annotate the specific method on the method of returning the string.
3. When there is no need to return to the page, you can directly use the @RestController annotation instead of @Controller and @ResponseBody to return the result directly.
Development IDE: idea 2022.1.3 Project architecture: SpringMVC

Qiufeng wrote in Zibo, business contact and technical exchange: Q375172665

Guess you like

Origin blog.csdn.net/hmwz0001/article/details/131734553