package cn.edu.tju;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
public class TestRequest2 {
public static void main(String[] args) {
RestTemplate restTemplate = new RestTemplate();
String url="http://localhost:8097/hiHeader2";
HttpHeaders headers = new HttpHeaders();
headers.add("token", "abcdefghijklmnopqrstuvwxyz1234567890");
HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity<>(headers);
ResponseEntity<String> resultEntity = restTemplate.exchange(url, HttpMethod.GET, httpEntity, String.class);
System.out.println(resultEntity.getBody());
}
}