public class text private static final String BASE_URL = http1007189432600cuchulainnopenapiassetPod; private static final String USERNAME = admin; private static final String PASSWORD = admi
<p>可以使用TypeReference来将返回的Map转换为List<pod>,代码如下:</p>
<p>public static void main(String[] args) {
RestTemplate restTemplate = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.setBasicAuth(USERNAME,PASSWORD);
HttpEntity<Object> entity = new HttpEntity<>(headers);
ResponseEntity<Map<String, List<Pod>>> response = restTemplate.exchange(BASE_URL, HttpMethod.GET, entity, new ParameterizedTypeReference<Map<String, List<Pod>>>() {});
List<Pod> pods = response.getBody().get("items");
}</p>
<p>其中,response.getBody().get("items")获取到的是Map中key为"items"的List<Pod></p>
原文地址: http://www.cveoy.top/t/topic/gSHG 著作权归作者所有。请勿转载和采集!