嗨,我希望客户端使用restfull Web服务。我使用springboot,服务返回一个只有一个OBJECT的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>>() {});