Spring boot下的Spring mvc 和之前的Spring mvc使用是完全一样的:
@Controller
即为Spring mvc的注解,处理http请求;
@RestController
Spring4后新增注解;
是@Controller与@ResponseBody的组合注解;
用于返回字符串或json数据;
该控制器类中所有的方法前面不需要在添加@ResponseBody注解了,但是固定了给控制器类中所有的方法只能返回json了,不方便,所以一般不使用该注解
@ResponseBody public Object list(){}
@GetMapping
RequestMapping 和 Get请求方法的组合;
等价于之前的
@PostMapping
RequestMapping 和 Post请求方法的组合;
@PutMapping
RequestMapping 和 Put请求方法的组合;
@DeleteMapping
RequestMapping 和 Delete请求方法的组合;