确定找到了答案。
exchange()是最好的方法。奇怪的是,
HttpEntity该类没有
setBody()方法(它具有
getBody()),但是仍然可以通过构造函数设置请求主体。
// Create the request body as a MultiValueMapMultiValueMap<String, String> body = new linkedMultiValueMap<String, String>();body.add("field", "value");// Note the body object as first parameter!HttpEntity<?> httpEntity = new HttpEntity<Object>(body, requestHeaders);MyModel model = restTemplate.exchange("/api/url", HttpMethod.POST, httpEntity, MyModel.class);


