如题所述
第1个回答 2017-05-09
官方文档中有介绍:
@RestController is a stereotype annotation that combines @ResponseBody and @Controller.
也就是说
@RestController注解相当于@ResponseBody、@Controller这两个注解的结合。
所以在定义Controller的时候如果需要返回jsp界面就用@Controller注解,只需要返回string或json的时候就用@RestController注解。
@RestController is a stereotype annotation that combines @ResponseBody and @Controller.
也就是说
@RestController注解相当于@ResponseBody、@Controller这两个注解的结合。
所以在定义Controller的时候如果需要返回jsp界面就用@Controller注解,只需要返回string或json的时候就用@RestController注解。