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