<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&lt;&gt;(headers);
ResponseEntity&lt;Map&lt;String, List<Pod>&gt;&gt; response = restTemplate.exchange(BASE_URL, HttpMethod.GET, entity, new ParameterizedTypeReference&lt;Map&lt;String, List<Pod>&gt;&gt;() {});
List<Pod> pods = response.getBody().get(&quot;items&quot;);
}</p>
<p>其中,response.getBody().get(&quot;items&quot;)获取到的是Map中key为&quot;items&quot;的List<Pod></p>
public class text private static final String BASE_URL = http1007189432600cuchulainnopenapiassetPod; private static final String USERNAME = admin; private static final String PASSWORD = admi

原文地址: http://www.cveoy.top/t/topic/gSHG 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录