当前位置: 首页 > wzjs >正文

建设服装网站目的杭州seo排名公司

建设服装网站目的,杭州seo排名公司,多种成都网站建设,视频拍摄技巧发送get请求时,发送请求头(Header)中的内容 方便第二次调用其他url时传递参数,例如userCode或者租户编码 调用方式 Autowired private HttpServletRequest request;先注入HttpServletRequestpublic xxx xxx(){String url &quo…

发送get请求时,发送请求头(Header)中的内容

方便第二次调用其他url时传递参数,例如userCode或者租户编码

调用方式

@Autowired
private HttpServletRequest request;先注入HttpServletRequestpublic xxx xxx(){String url = "http://" + ip +":8082/inAndOut/into/xxxxxx";String userCode = request.getHeader("usercode");//动态传递Header中的userCode,用来给组件服务接口传userCodeMap<String, String> headers = new HashMap<>();headers.put("Content-Type", "application/json");headers.put("Authorization", "Bearer your_token_here");headers.put("tenantcode", tenantCode);headers.put("userCode", userCode);String request = HttpClientUtil.sendGetWithHeaders(url,headers);
}

userCode和tenantCode可以从Header中获取,前端也一样,这是在PostMan中测试

工具类

import org.apache.http.HttpEntity;
import org.apache.http.HttpHeaders;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;import java.io.IOException;
import java.util.HashMap;
import java.util.Map;public class GetWithHeadersExample {public static void main(String[] args) {Map<String, String> headers = new HashMap<>();headers.put("Content-Type", "application/json");headers.put("Authorization", "Bearer your_token_here");String url = "http://example.com/api/endpoint";try {String response = sendGetWithHeaders(url, headers);System.out.println("Response: " + response);} catch (IOException e) {e.printStackTrace();}}public static String sendGetWithHeaders(String url, Map<String, String> headers) throws IOException {CloseableHttpClient httpClient = HttpClients.createDefault();HttpGet httpGet = new HttpGet(url);for (Map.Entry<String, String> entry : headers.entrySet()) {httpGet.addHeader(entry.getKey(), entry.getValue());}HttpResponse response = httpClient.execute(httpGet);HttpEntity entity = response.getEntity();String responseBody = EntityUtils.toString(entity);httpClient.close();return responseBody;}
}

http://www.dtcms.com/wzjs/340753.html

相关文章:

  • php网站开发难吗seo优化员
  • 网站开发就业岗位今日新闻头条热点
  • 电商网站平台网络推广哪家好
  • 玉溪网站建设现状免费做网站
  • 做亚马逊网站需要租办公室吗网页制作与网站建设实战教程
  • 织梦网站建设教程如何做网站建设
  • 网站邮件发送功能怎么做百度的网页地址
  • 浙江省住房和城乡建设局网站首页seo网站推广怎么做
  • wordpress收藏夹赣州seo顾问
  • wordpress搜索全站店铺推广方式有哪些
  • 怎么才能登网站做外贸公司运营策划营销
  • 做公司网站哪里好app用户量排名
  • 网站策划书籍推荐torrentkitty磁力搜索引擎
  • 泰州外贸网站设计获客渠道找精准客户
  • dede免费网站模板下载网络代理app
  • 房地产管理局网站徐州网站建设方案优化
  • 郑州网站优化公司百度pc网页版登录入口
  • 网站开发课程技术培训seo技术306
  • 求个网站好人有好报2022如何用模板做网站
  • 政府网站城市建设栏目内容青岛seo网站管理
  • 图库素材网站百度快照官网
  • 建站最好的公司排名网站优化推广费用
  • 网站做词长沙新媒体营销
  • 建设批发网站友情链接百科
  • 西部数码网站流量怎么充网站自助搭建
  • 张家界网站制作公司nba最新交易消息
  • 大连微网站建设资源网站排名优化seo
  • pandorabox 做网站关键词推广是什么意思
  • php网站做语言包找网络公司做推广费用
  • 怎样临沂网站建设百度交易平台