jiazx0107@163.com
2023-11-18 328eba66ddc6fdf2f324b9cd04cd6acec9f642de
src/main/java/com/fzzy/gateway/util/GatewayHttpUtil.java
@@ -20,12 +20,13 @@
    /**
     * 执行GET请求
     *
     * @param url
     * @param paramsMap
     * @return
     * @throws Exception
     */
    public static String doGet(String url,Map<String, String> paramsMap) throws Exception{
    public static String doGet(String url, Map<String, String> paramsMap) throws Exception {
        CloseableHttpClient client = HttpClients.createDefault();
        String responseText = "";
        CloseableHttpResponse response = null;
@@ -33,7 +34,7 @@
            String getUrl = url + "?";
            if (paramsMap != null) {
                for (Map.Entry<String, String> param : paramsMap.entrySet()) {
                  //  getUrl += param.getKey() + "=" + URLEncoder.encode(param.getValue(), "UTF-8") + "&";
                    //  getUrl += param.getKey() + "=" + URLEncoder.encode(param.getValue(), "UTF-8") + "&";
                    getUrl += param.getKey() + "=" + URLEncoder.encode(param.getValue(), "UTF-8") + "&";
                }
            }
@@ -47,18 +48,17 @@
            HttpEntity entity = response.getEntity();
            if (entity != null) {
                responseText = EntityUtils.toString(entity,"UTF-8");
                responseText = EntityUtils.toString(entity, "UTF-8");
            }
        } catch (Exception e) {
            log.error("http request failed", e);
            log.error("http request failed--{}", e.getMessage());
        } finally {
            try {
                response.close();
                if (null != response) response.close();
            } catch (Exception e) {
                log.error("", e);
            }
        }
        return responseText;
    }