接受別人的接口的參數類型有錯誤,可以試試 String.
HttpHeaders headers = new HttpHeaders();
headers.set("token", "XXXX");
MultiValueMap<String, Object> multiValueMap = new LinkedMultiValueMap<>();
//參數列表
multiValueMap.add("xxx", xxx);
HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(multiValueMap, headers);
//url = ip
ResponseEntity<String> response = RestTemplateUtils.getRestTemplate().exchange(url, HttpMethod.POST, requestEntity, String.class);
//import org.apache.commons.lang.StringEscapeUtils;
String s = StringEscapeUtils.unescapeJavaScript(response.getBody());
MyObjectbody = gson.fromJson(s, MyObject.class);