RestTemplate 返回值嵌套范型解析


接口返回值定义如下:ResponseEntity<ValuationResponseEntity<DealChangeNotifyVO>>

1 ParameterizedTypeReference<ValuationResponseEntity<DealChangeNotifyVO>> typeRef = new ParameterizedTypeReference<ValuationResponseEntity<DealChangeNotifyVO>>() {};
2 HttpHeaders headers = new HttpHeaders();
3 headers.setContentType(MediaType.APPLICATION_JSON);
4 headers.set("Accept", "application/json");
5 HttpEntity<Object> requestEntity = new HttpEntity<>(requestBody, headers);
6 ResponseEntity<ValuationResponseEntity<DealChangeNotifyVO>> response = restTemplate.exchange(url, HttpMethod.POST, requestEntity, typeRef);
7 return response;



原文地址:https://www.cnblogs.com/xushy/p/15015400.html