传递参数
方式一
@GetMapping(value = "/get/{id}")
public Result getUser(@PathVariable Long id) {
return "hello";
}
方式二
post或get均可
@PostMapping(value = "/add")
public Result addUser(@RequestParam("username") String username,
@RequestParam("name") String name) {
return "hello";
}
方式三
@PostMapping(value = "/add")
public Result addUser(@ModelAttribute("userInfo") UserInfo userInfo) {
return "hello";
}
注:在fiddler中模拟post无效时,添加
Content-Type: application/x-www-form-urlencoded