public static String doGet(String url,String token) throws IOException {
//指定请求路径及方式
HttpGet httpGet = new HttpGet(url);
//创建请求客户端
HttpClient httpClient = new DefaultHttpClient();
//执行请求,并得到返回结果
HttpResponse httpResponse = httpClient.execute(httpGet);
return httpResponse;
}

springboot项目中怎样将token添加到请求头中
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
2条回答 默认 最新
- 秃头批风侠 2022-04-21 14:31关注
URL url = new URL("你的请求地址"); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestProperty("token",“你的token”);
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 1无用