【发布时间】:2012-01-07 23:50:04
【问题描述】:
我必须进行包含自定义标头和查询参数的REST 调用。我将HttpEntity 设置为仅使用标题(无正文),并使用RestTemplate.exchange() 方法如下:
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);
这在客户端失败,dispatcher servlet 无法将请求解析到处理程序。调试了一下,好像没有发送请求参数。
当我使用请求正文和没有查询参数的POST 进行交换时,它工作得很好。
有人有什么想法吗?
【问题讨论】: