RestTemplate返回值带有泛型

public class HttpTest {
    @Autowired
    private RestTemplate restTemplate;

    @Test
    public void test() {
        List list = new ArrayList<>();
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("id", "aaa");
        jsonObject.put("name", "bbb");
        list.add(jsonObject);
        HttpHeaders headers = new HttpHeaders();
        headers.setContentType(MediaType.APPLICATION_JSON);

        HttpEntity> requestEntity = new HttpEntity<>(list, headers);
        ResponseEntity>> result =
                restTemplate.exchange("https://www.xxx.com",
                        HttpMethod.POST, requestEntity, new ParameterizedTypeReference>>() {
                        });
        System.out.println("aaa");
    }

}

你可能感兴趣的:(RestTemplate返回值带有泛型)