public String sendGetRequest(String reqURL, Map paramMap, String decodeCharset){ // 创建Httpclient对象 CloseableHttpClient httpclient = HttpClients.createDefault(); String resultString = ""; CloseableHttpResponse response = null; //处理URL的一些传参 if (!paramMap.isEmpty()) { for (String key : paramMap.keySet()) { if (reqURL.indexOf('?') == -1) { reqURL += "?" + key + "=" + paramMap.get(key); } else { reqURL += "&" + key + "=" + paramMap.get(key); } } } try { HttpGet httpGet = new HttpGet(reqURL); // 执行请求 response = httpclient.execute(httpGet); response.setHeader("Content-Type", "application/json"); // 判断返回状态是否为200 if (response.getStatusLine().getStatusCode() == 200) { resultString = EntityUtils.toString(response.getEntity(), "UTF-8"); } } catch (Exception e) { e.printStackTrace(); } finally { try { if (response != null) { response.close(); } httpclient.close(); } catch (IOException e) { e.printStackTrace(); } } return resultString;}