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;

 





免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM