我必须进行包含自定义标题和查询参数的REST调用。我把我的HttpEntity
只用头(无正文)我用的是RestTemplate.exchange()方法如下:Spring RestTemplate GET参数
HttpHeaders headers = new HttpHeaders();
headers.set("Accept", "application/json");
Map<String, String> params = new HashMap<String, String>();
params.put("msisdn", msisdn);
params.put("email", email);
params.put("clientVersion", clientVersion);
params.put("clientType", clientType);
params.put("issuerName", issuerName);
params.put("applicationName", applicationName);
HttpEntity entity = new HttpEntity(headers);
HttpEntity<String> response = restTemplate.exchange(url, HttpMethod.GET, entity, String.class, params);
这种失败在与调度的servlet暂时无法在客户端解析请求到处理程序。 Havinf调试它,它看起来像请求参数没有被发送。
当我使用请求体某条信息的交流,并没有查询参数它工作得很好。
有没有人有任何想法?
是否适合你?我遵循使用UriComponentsBuilder的相同方法,但在目标URL处,当我执行request.getAttribute()时,我得到null。 – yathirigan
见上:https://stackoverflow.com/a/16676827 – Marc