免责声明:我不是 J2EE 开发人员。但是这段代码在其他地方也能用,但是这个 api 快疯了。
代码
@GET
@Path("GetCloseby")
@Consumes({ MediaType.TEXT_PLAIN })
@Produces({ MediaType.APPLICATION_JSON })
public CServiceCenters getList(@QueryParam("latitude") Double latitude,
@QueryParam("longitude") Double longitude) {
log.info("GetCloseby searching for lat "
+ latitude + " lng " + longitude);
GetCloseby searching for lat 17.63 lng null
来自客户的电话
curl http://:8080/MYWAR/MYAPI/GetCloseby?latitude=17.63&longitude=73.9
最佳答案
免责声明:我不是 cURL 的大用户,所以我不知道所有的细微差别,也不知道它为什么有效。可能是shell的问题。
为了让它工作,我必须在 url 周围添加引号 "
curl "http://:8080/MYWAR/MYAPI/GetCloseby?latitude=17.63&longitude=73.9"
注意:我也尝试转义 &
(不带引号),但我会得到服务器的 URISyntaxExeption。
关于java - 为什么我的 QueryParam 返回 null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27244155/