From 18bd055f869fb9ecb748c6c912d59a405f851f57 Mon Sep 17 00:00:00 2001 From: xioayue Date: Mon, 4 Jul 2022 10:05:47 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=B7=E6=B1=82=E5=A4=B4=E5=8F=98=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/cn/chjyj/szwh/utils/RequestUtils.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/cn/chjyj/szwh/utils/RequestUtils.java b/src/main/java/cn/chjyj/szwh/utils/RequestUtils.java index df527be..2b8395c 100644 --- a/src/main/java/cn/chjyj/szwh/utils/RequestUtils.java +++ b/src/main/java/cn/chjyj/szwh/utils/RequestUtils.java @@ -26,10 +26,11 @@ public class RequestUtils { /** * 利用GET方式获取uri数据 * @param requri 请求地址 + * @param hkey 请求头键名 * @param token 访问凭据 * @return */ - public static JSONObject doGetUrlData(String requri,String token){ + public static JSONObject doGetUrlData(String requri,String hkey,String token){ JSONObject jsonObject = new JSONObject(); try { URL url = new URL(requri); @@ -38,8 +39,8 @@ public class RequestUtils { httpcon.setDoOutput(true); httpcon.setDoInput(true); // 存在token的时候 - if(StringUtils.isNotEmpty(token)){ - httpcon.addRequestProperty("api_token",token); + if(StringUtils.isNotEmpty(token) && StringUtils.isNotEmpty(hkey)){ + httpcon.addRequestProperty(hkey,token); } httpcon.connect(); //获取返回的字符