【发布时间】:2019-03-30 06:09:23
【问题描述】:
我是 web 服务的新手,正在使用 spring-boot 来创建 web 服务,而在使用 http://localhost:8085/user/30?name=abc 发出请求时,我的 id 属性为空。`
@GetMapping(value="{id}", produces = MediaType.APPLICATION_JSON_VALUE)
public String getUser(@PathParam("id") Long id,
@QueryParam("name") String name){
System.out.println(" Got id by path param : "+ id + " And Got name using Query Param " +name);
return " Got id by path param : "+ id + " And Got name using Query Param " +name;
}
编辑添加截图。
【问题讨论】:
-
你想从请求中得到什么?用户名,或使用查询参数
name? 指定的任何用户参数。 -
@Boris QueryParam 工作正常,但使用 PathParam
标签: rest web-services spring-boot