我尝试触发一个 http GET 请求
它应该如下:
https://www.my_service.com/myRequest?from=x%3A34.78104114532471+y%3A31.243920719573723&to=x%3A34.77901339530945+y%3A31.242416368424312&
我写了这段代码
webResource.accept("application/json");
ClientResponse response = webResource.path("myRequest")
.queryParam("from", "x%3A34.78104114532471+y%3A31.243920719573723")
.queryParam("to", "x%3A34.77901339530945+y%3A31.242416368424312")
.accept(MediaType.APPLICATION_JSON_TYPE)
.get(ClientResponse.class);
if (response.getStatus() != 200) {
throw new RuntimeException("Failed : HTTP error code : "
+ response.getStatus());
}
生成此网址:
https://www.my_service.com/myRequest?from=x%3A34.78104114532471+y%3A31.243920719573723&to=x%3A34.77901339530945+y%3A31.242416368424312&
但这会返回 404 错误。
我已经在浏览器中尝试了这两个网址。唯一的区别被+
替换为%2B
+
对我有用,但%2B
没有。
我怎样才能使代码不替换+
为%2B
?