当前位置 博文首页 > 白徽的博客:spring boot put方法有参数时如何编写与访问
先说明自己遇到的问题:
后台编写put方法接收参数。
@RequestMapping(value = "/updataName/{id}/",method = RequestMethod.PUT)
public Object updataName(@PathVariable("id") Integer id){
System.out.println("现在开始接受参数");
System.out.println(id);
// System.out.println();
return null;
}
访问是通过ApiPost的方式来个截图
请教别人后发现:
请求写的有问题
应该写成:
localhost:8888/students/updataName/23/
那么假如是多个参数怎么接收与访问?
@RequestMapping(value = "/updataName/{id}/{name}/",method = RequestMethod.PUT)
public Object updataName(@PathVariable("id") Integer id,@PathVariable("name") String name){
System.out.println("现在开始接受参数");
System.out.println(id+" "+name);
// System.out.println();
return null;
}
访问:
localhost:8888/students/updataName/23/mike/
cs