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;

 




posted on 2021-07-15 14:27  xushy  阅读(879)  评论(0编辑  收藏  举报

导航