我想在运行时添加查询参数传统上我们使用url来做?a = b& b = c& so ... 但我不知道参数长度所以我想动态添加查询参数 怎么做到这一点?
答案 0 :(得分:4)
您可以使用WebClient.query(String, Object...)
向CXF WebClient添加任意数量的参数。例如,如果您有参数Map,则可以执行以下操作:
Map<String, String> params = new HashMap<>();
params.put("foo", "hello");
params.put("bar", "world");
WebClient webClient = WebClient.create("http://url");
for (Entry<String, String> entry : params.entrySet()) {
webClient.query(entry.getKey(), entry.getValue());
}
Response res = webClient.get();
这将导致向/url?foo=hello&bar=world