springframe参数注解

2018-10-29  本文已影响0人  inverseli
关于参数问题的注解

@RequestParam
@RequestBody
@PathVariable

注解解释
//controller方法
@GetMapping("/book") //input框中name属性不一致时,@RequestParam内要进行绑定
public void test(@RequestParam("page") int page) {}
// method:get http://localhost:8080/book?page=2
// @RequestBody 可以接收实体
@PostMapping
public void test(@RequestBody User user) {}
@GetMapping("user/{id}")
public void test(@PathVariable Integer id) {}
// 访问路径 http://localhost:8080/book/2

postman测试参数:

上一篇 下一篇

猜你喜欢

热点阅读