@PathVariable
直接将参数传到路径上面时 用@PathVariable
@GetMapping("{id}")
public R<Employee> getById(@PathVariable Long id){
return null;
}
@RequestBody
异步提交发送,参数通过请求体传送json数据时用@RequestBody

@PutMapping
public R<String> update(@RequestBody Employee employee){
}
不加注解
请求路径中的参数是以?进行拼接的时候 ,不用注解
public R<Page> page(int page,int pageSize,String name){
return null;
}
SpringMVC中的参数绑定:@PathVariable与@RequestBody
这篇文章介绍了在SpringMVC中如何处理HTTP请求的不同方式。@PathVariable用于从URL路径中获取参数,@RequestBody则用来接收请求体中的JSON数据。@GetMapping和@PutMapping分别是HTTP的GET和PUT操作,展示了如何在这些操作中使用注解处理参数。
1972

被折叠的 条评论
为什么被折叠?



