0
我試圖從響應頭部獲取一些認證值並獲取填充對象。但我的問題是,我得到的是標題值或填充對象,如示例中所示。從RestTemplate獲取標題數據和對象
RestTemplate restTemplate = new RestTemplate();
String requestJson = "{ \"identifier\": \"username\", \"password\": \"pw\" } ";
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.add("KEY","apikey");
HttpEntity<String> entity = new HttpEntity<String>(requestJson,headers);
Login login = restTemplate.postForObject("https://url.com",entity, Login.class);
或
HttpEntity<String> response = template.exchange("https://url.com", HttpMethod.POST, entit, Login.class);
String resultString = response.getBody();
HttpHeaders headers = response.getHeaders();
有沒有辦法做到的響應=>對象交換以後呢? 或者完全不同的方式來解決這個問題?