springboot中controller层几种不同传参方式对比
注释方式
解释说明
server书写
参数接收
客户端请求
@PathVariable
直接读取请求路径中的参数;适合单个参数传递
@GetMapping("/ceshi/{id}")
@PathVariable(name = “id”) String id
http://localhost:8080/ceshi/11
@RequestParam
读取多个参数时使用;适合GET请求多个参数传递
@GetMapping("/ceshi/{id}")
@RequestParam(name ...
原创
2021-04-08 10:51:02 ·
1020 阅读 ·
0 评论