@RestController
第一种写法(常规写法)
@Controller public class HelloController { @ResponseBody @RequestMapping("/helloQuick") public String hello(){ return "hello world quick!"; } }
第二种写法
这种写法使用于整个类的方法 都以josn的方式返回给前端。
@ResponseBody @Controller public class HelloController { @RequestMapping("/helloQuick") public String hello(){ return "hello world quick!"; } }
第三种
@RestController就相当于@ResponseBody和@Controller的组合
@RestController public class HelloController { @RequestMapping("/helloQuick") public String hello(){ return "hello world quick!"; } }