这里有两种方式:看图或者看下面的代码 第一种是通过@PathVariable("id") 由于第一种的参数比较多,所以我们用第二种的方法 让它传入一个JSON数据。
@PutMapping("/update/{id}") @ResponseBody public void update(@PathVariable("id") Integer id, @RequestParam("name") String name, @RequestParam("age") Integer age){ User user=new User(); user.setId(id); user.setAge(age); user.setName(name); userService.sava(user);//存在问题 } @PutMapping("/update1") public void update1(@RequestBody User user){ // UserInfo userInfo1=new UserInfo(); // userInfo1.setId(id); // userInfo1.setUsername(username); // userInfo1.setUserage(userage); userService.sava(user);//存在问题 }
http://localhost:8080/api/update/22?name=pMD&age=89
http://localhost:8080/api/update1
看看其他层 :
项目链接:链接:https://pan.baidu.com/s/1-OsNGz7olFU07XxTO3ykUQ 密码:neef 要是链接失效,可以给我发邮件索要[email protected]