這是關於如何在頭文件中包含參數的代碼片段。
public static HttpEntity<Object> createLMIHttpEntity(String username,
String password, String lastSyncDate, String pageSize,
String pageNumber) {
MultiValueMap<String, String> headers =
new LinkedMultiValueMap<String, String>();
headers.add("Accept", "application/json");
headers.add("userName", username);
headers.add("password", password);
headers.add("lastSyncDate", lastSyncDate);
headers.add("pageSize", pageSize);
headers.add("pageNumber", pageNumber);
return new HttpEntity<Object>(headers);
}
這時你可以用它來執行這樣的電話:
ResponseEntity<String> response = restTemplate.exchange(url, httpMethod , requestEntity, String.class);
讓我知道如果你需要更多的信息。