@GetMapping @PostMapping @PutMapping @DeleteMapping @PathVariable(占坑)

springboot 增删改查

@GetMapping @PostMapping  @PutMapping @DeleteMapping

 

@PathVariable

通过 @PathVariable 可以将URL中占位符参数{xxx}绑定到处理器类的方法形参中@PathVariable(“xxx“

@GetMapping("/{id}")
@ResponseBody
public User getUsersById(@PathVariable int id) {
return new User(id,"sunrui","123");
}

 

 

 

 

@ResponseBody

绕开视图解析器,返回json对象

 

@GetMapping
@ResponseBody
public List<User> getUsers(){
return userService.queryUserList();
}

 

 

 

@RequestBody

public String addUsers(@RequestBody User user){
return "success";
}

 

 

 

 

 

 

 

 


posted @ 2021-01-29 17:02  Master_Sun  阅读(439)  评论(0编辑  收藏  举报