SpringCloud: RestTemplate 带header发送get请求

网友投稿 215 2022-08-23

SpringCloud: RestTemplate 带header发送get请求

package cn.edu.tju;import org.springframework.org.springframework.org.springframework.org.springframework.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=" HttpHeaders headers = new HttpHeaders(); headers.add("token", "abcdefghijklmnopqrstuvwxyz1234567890"); HttpEntity> = new HttpEntity<>(headers); ResponseEntity resultEntity = restTemplate.exchange(url, HttpMethod.GET, String.class); System.out.println(resultEntity.getBody()); }}

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:诡异设计过火营销,企业广告为何频踩雷!
下一篇:java: 三个线程交替打印A、B、C
相关文章

 发表评论

暂时没有评论,来抢沙发吧~