RestTemplate 遇到泛型参数时,用exchange方法

#发送参数:

EpbParam param = new EpbParam();
param.setData(CouponOrder);


#参数 httpEntity组装
 HttpHeaders headers = new HttpHeaders();
 headers.setContentType(MediaType.APPLICATION_JSON);
 HttpEntity> entity = new HttpEntity>(param, headers);




#返回值 ParameterizedTypeReference
ParameterizedTypeReference parameterizedTypeReference = new ParameterizedTypeReference>() {};
ResponseEntity> result = restTemplate.exchange(url, HttpMethod.POST, entity, parameterizedTypeReference);result.getBody();




你可能感兴趣的:(java,restTemplate,exchange,泛型)