您好,我希望客户端使用Restfull Web服务。我使用springboot,该服务仅返回一个对象就返回一个JSON列表。我想像这样使用RestTemplate的postForObject Api
ResponseEntity<List<RetrieveRichiestaResponseDto>> result = restTemplate.postForObject(
uri,
entity,
new ParameterizedTypeReference<List<RetrieveRichiestaResponseDto>>() {});
为什么会给我这个错误
> The method postForObject(String, Object, Class<T>, Object...) in the
> type RestTemplate is not applicable for the arguments (String,
> HttpEntity<capture#3-of ?>, new
> ParameterizedTypeReference<List<RetrieveRichiestaResponseDto>>(){})
感谢您的帮助!
[restTemplate.postForObject()
不支持ParameterizedTypeReference<>
使用restTemplate.exchange()
ResponseEntity<List<RetrieveRichiestaResponseDto>> result = restTemplate.exchange(uri, HttpMethod.POST, entity,
new ParameterizedTypeReference<List<RetrieveRichiestaResponseDto>>() {}).getBody();