12
Spring RestTemplate GET与参数
我必须打一个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使用请求正文和无查询参数进行交换时,它工作正常。 有人有什么想法吗?