1、get 请求
@GetMapping("user/list") // 等价于@RequestMapping(value="user/list",method=RequestMethod.GET)
@ResponseBody
public List list(){
// TODO
return null;
}
2、post 请求
@PostMapping("user/add") // 等价于@RequestMapping(value="user/add",method=RequestMethod.POST)
@ResponseBody
public List add(@RequestBody User user){
// TODO
return null;
}
3、put 请求
@PutMapping("/user/{userId}") // 等价于@RequestMapping(value="/user/{userId}",method=RequestMethod.PUT)
@ResponseBody
public List update(@PathVariable(value = "userId") Long userId,
@RequestBody User user){
// TODO
return null;
}
4、delete 请求
@DeleteMapping("/user/{userId}") // 等价于@RequestMapping(value="/user/{userId}",method=RequestMethod.DELETE)
@ResponseBody
public List delete(@PathVariable(value = "userId") Long userId){
// TODO
return null;
}
5、patch 请求
@PatchMapping("/user/profile") // 一般实际项目中,我们都是 PUT 不够用了之后才用 PATCH 请求去更新数据。
@ResponseBody
public List updateUser(@RequestBody User user){
// TODO
return null;
}