在 jersey 版本 1.4 中(至少这是我可以在网上找到的唯一引用)有 com.sun.jersey.api.client.WebResource
,您可以在其中使用 Webresource 发送参数列表。 queryParams() ... 似乎该方法不再存在于 jersey-client 2.x 中 ... 我想它仍然可以做到这一点(无需手动组合查询字符串)?类 WebTarget 有一个方法:
public WebTarget queryParam(String name, Object... values);
但没有 queryParams() 方法。
最佳答案
只需多次调用 queryParam() 即可。比如
target.queryParam("foo", "fooValue").queryParam("bar", "barValue");
或者如果您有 map ,您可以遍历条目:
for (Map.Entry<String, Object> entry : map.entrySet()) {
target = target.queryParam(entry.getKey(), entry.getValue());
}
关于java - 在 jersey 2.x 中使用 GET 将查询参数列表发送到 jersey 客户端?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33312304/