public static String httpGet(String url) {
        // get请求返回结果
        String strResult = "";
        try {
            DefaultHttpClient client = new DefaultHttpClient();
            // 发送get请求
            HttpGet request = new HttpGet(url);
            HttpResponse response = client.execute(request);

            /** 请求发送成功,并得到响应 **/
            if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
                /** 读取服务器返回过来的json字符串数据 **/
                strResult = EntityUtils.toString(response.getEntity());
            }
        } catch (IOException e) {
            System.out.println("get请求提交失败:" + url);
        }
        return strResult;
    }

 

相关文章:

  • 2022-12-23
  • 2023-03-21
  • 2022-12-23
  • 2021-10-11
  • 2021-10-16
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-09-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-08
相关资源
相似解决方案