zoukankan      html  css  js  c++  java
  • spring之httpclient doget请求

    /**
         * @param url        请求地址
         * @param jsonString 加密后的字符串
         * @return
         * @throws ClientProtocolException
         * @throws IOException             返回请求后的报文  JSON字符串
         */
        public static String doGet(String url, String jsonString) throws IOException {

            // 创建Httpclient对象
            CloseableHttpClient httpClient = HttpClients.createDefault();
            CloseableHttpResponse response = null;
            String resultString = "";
            // 创建参数列表
            if (jsonString != null & !"".equals(jsonString)) {
                StringEntity strEnt = new StringEntity(jsonString.toString(), "UTF-8");//解决中文乱码问题
                strEnt.setContentEncoding("UTF-8");
                strEnt.setContentType("application/json");
            }
            // 创建Http get请求
            HttpGet httpGet = new HttpGet(url+"?"+jsonString);
            // 执行http请求
            response = httpClient.execute(httpGet);
            resultString = EntityUtils.toString(response.getEntity(), "UTF-8");
            return resultString;
        }

  • 相关阅读:
    虚拟内存思想
    虚拟内存映射 段分割 vm_area_struct
    进程、内存的理想与现实 VS 虚拟内存
    进程地址空间
    MMU CPU及思想
    链接器和加载器 好书
    编译器 链接器 加载器
    链接器简介
    C编译器、链接器、加载器详解
    静态库是.o文件的集合与弱符号
  • 原文地址:https://www.cnblogs.com/wirr/p/8397729.html
Copyright © 2011-2022 走看看