Spring/json: Convert a typed collection like List

后端 未结 3 917
悲哀的现实
悲哀的现实 2020-12-08 13:39

I\'m trying to marshal a list: List objects via the Spring Rest Template.

I can pass along simple Pojo objects, but I can\'t fi

3条回答
  •  不思量自难忘°
    2020-12-08 14:25

    In Spring 3.2 there is now support for generic types using the new exchange()-methods on the RestTemplate:

     ParameterizedTypeReference> typeRef = new ParameterizedTypeReference>() {};
     ResponseEntity> response = template.exchange("http://example.com", HttpMethod.GET, null, typeRef);
    

    Works like a charm!

提交回复
热议问题