当前位置: 首页 > article >正文

HTTP 四、HttpClient的使用

一、简单介绍

        1、简介

        HttpClient是Apache Jakarta Common下的子项目,用来提供高效的、最新的、功能丰富的支持HTTP协议的客户端编程工具包,并且它支持HTTP协议最新的版本和建议。HttpClient已经应用在很多的项目中,比如Apache Jakarta上很著名的另外两个开源项目Cactus和HTMLUnit都使用了HttpClient。

         HTTP和浏览器有点像,但却不是浏览器。很多人觉得既然HttpClient是一个HTTP客户端编程工具,很多人把他当做浏览器来理解,但是其实HttpClient不是浏览器,它是一个HTTP通信库,因此它只提供一个通用浏览器应用程序所期望的功能子集,最根本的区别是HttpClient中没有用户界面,浏览器需要一个渲染引擎来显示页面,并解释用户输入,例如鼠标点击显示页面上的某处,有一个布局引擎,计算如何显示HTML页面,包括级联样式表和图像。javascript解释器运行嵌入HTML页面或从HTML页面引用的javascript代码。来自用户界面的事件被传递到javascript解释器进行处理。除此之外,还有用于插件的接口,可以处理Applet,嵌入式媒体对象(如pdf文件,Quicktime电影和Flash动画)或ActiveX控件(可以执行任何操作)。HttpClient只能以编程的方式通过其API用于传输和接受HTTP消息。

      2、特性:
  1. 基于标准、纯净的java语言。实现了Http1.0和Http1.1
  2. 以可扩展的面向对象的结构实现了Http全部的方法(GET, POST, PUT, DELETE, HEAD, OPTIONS, and TRACE)。
  3.  支持HTTPS协议。
  4. 通过Http代理建立透明的连接。
  5. 利用CONNECT方法通过Http代理建立隧道的https连接。
  6. Basic, Digest, NTLMv1, NTLMv2, NTLM2 Session, SNPNEGO/Kerberos认证方案。
  7.  插件式的自定义认证方案。
  8. 便携可靠的套接字工厂使它更容易的使用第三方解决方案。
  9. 连接管理器支持多线程应用。支持设置最大连接数,同时支持设置每个主机的最大连接数,发现并关闭过期的连接。
  10.  自动处理Set-Cookie中的Cookie。
  11. 插件式的自定义Cookie策略。
  12. Request的输出流可以避免流中内容直接缓冲到socket服务器。
  13. Response的输入流可以有效的从socket服务器直接读取相应内容。
  14.  在http1.0和http1.1中利用KeepAlive保持持久连接。
  15.  直接获取服务器发送的response code和 headers。
  16.  设置连接超时的能力。
  17. 实验性的支持http1.1 response caching。
  18. 源代码基于Apache License 可免费获取。

二、简单使用

        1、引入依赖

        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.5.13</version>
        </dependency>

        2、使用HttpClient发送请求、接收响应很简单,一般需要如下几步即可。

   //1. 创建HttpClient对象。
        CloseableHttpClient httpClient = HttpClientBuilder.create().build();


        //2. 创建请求方法的实例,并指定请求URL。
        // 如果需要发送GET请求,创建HttpGet对象;如果需要发送POST请求,创建HttpPost对象。
        HttpGet httpGet = new HttpGet("http://localhost:8090/emp/get");

        //3. 如果需要发送请求参数,可调用HttpGet、HttpPost共同的setParams(HttpParams params)方法来添加请求参数;
        // 对于HttpPost对象而言,也可调用setEntity(HttpEntity entity)方法来设置请求参数。
        
        // 响应模型
        CloseableHttpResponse response = null;
        try {
            // 4. 调用HttpClient对象的execute(HttpUriRequest request)发送请求,
            // 该方法返回一个HttpResponse。
            response = httpClient.execute(httpGet);

            // 从响应模型中获取响应实体
            //5. 调用HttpResponse的getAllHeaders()、getHeaders(String name)等方法可获取服务器的响应头;
            // 调用HttpResponse的getEntity()方法可获取HttpEntity对象,该对象包装了服务器的响应内容。程序可通过该对象获取服务器的响应内容。
            HttpEntity responseEntity = response.getEntity();
            System.out.println("响应状态为:" + response.getStatusLine());
            if (responseEntity != null) {
                System.out.println("响应内容长度为:" + responseEntity.getContentLength());
                System.out.println("响应内容为:" + EntityUtils.toString(responseEntity));
            }
        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (ParseException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                // 6. 释放连接。无论执行方法是否成功,都必须释放连接
                if (httpClient != null) {
                    httpClient.close();
                }
                if (response != null) {
                    response.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

三、各种使用案例

        1、GET请求  没有参数
       //1、创建HttpClient 客户端
        CloseableHttpClient httpClient = HttpClientBuilder.create().build();

        //2、 创建请求方法的实例,并指定请求URL
        HttpGet httpGet = new HttpGet("http://localhost:8090/user/get");

        //响应模型
        CloseableHttpResponse response = null;
        try {
            // 由客户端执行发送Get请求
            response = httpClient.execute(httpGet);
            // 从响应模型中获取响应实体
            HttpEntity responseEntity = response.getEntity();
            System.out.println("响应状态为:" + response.getStatusLine());
            if (responseEntity != null) {
                System.out.println("响应内容长度为:" + responseEntity.getContentLength());
                System.out.println("响应内容为:" + EntityUtils.toString(responseEntity));
            }

        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (ParseException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                // 释放资源
                if (httpClient != null) {
                    httpClient.close();
                }
                if (response != null) {
                    response.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        
        2、GET 请求 路径上拼接参数

        1)直接拼接参数


        String userId = "1";
        String userName = "张三";

        //1、创建HttpClient 客户端
        CloseableHttpClient httpClient = HttpClientBuilder.create().build();

        //参数 拼接
        StringBuffer params = new StringBuffer();
        try {
            // 字符数据最好encoding一下;这样一来,某些特殊字符才能传过去(如:某人的名字就是“&”,不encoding的话,传不过去)
            params.append("userId=" + URLEncoder.encode(userId, "utf-8"));
            params.append("&");
            params.append("userName="+ URLEncoder.encode(userName, "utf-8"));
        } catch (UnsupportedEncodingException e1) {
            e1.printStackTrace();
        }



        //2、 创建请求方法的实例,并指定请求URL
        HttpGet httpGet = new HttpGet("http://localhost:8090/user/get"+ "?" + params);

        //响应模型
        CloseableHttpResponse response = null;
        try {

            //添加配置信息
            RequestConfig requestConfig  = RequestConfig.custom()
                    //设置连接超时时间(单位毫秒)
                    .setConnectTimeout(5000)
                    //设置请求超时时间(单位毫秒)
                    .setConnectionRequestTimeout(5000)
                    //socket读写超时时间(单位毫秒)
                    .setSocketTimeout(50000)
                    //设置是否允许重定向(默认为true)
                    .setRedirectsEnabled(true).build();

            // 将上面的配置信息,添加到Get请求中
            httpGet.setConfig(requestConfig);

            // 由客户端执行发送Get请求
            response = httpClient.execute(httpGet);
            // 从响应模型中获取响应实体
            HttpEntity responseEntity = response.getEntity();
            System.out.println("响应状态为:" + response.getStatusLine());
            if (responseEntity != null) {
                System.out.println("响应内容长度为:" + responseEntity.getContentLength());
                System.out.println("响应内容为:" + EntityUtils.toString(responseEntity));
            }

        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (ParseException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                // 释放资源
                if (httpClient != null) {
                    httpClient.close();
                }
                if (response != null) {
                    response.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        2)使用URI获得HttpGet

   String userId = "1";
        String userName = "张三";

        //1、创建HttpClient 客户端
        CloseableHttpClient httpClient = HttpClientBuilder.create().build();

        // 使用URI 拼接好请求路径
        URI uri = null;
        try {
            // 将参数放入键值对类NameValuePair中,再放入集合中
            List<NameValuePair> params = new ArrayList<>();
            params.add(new BasicNameValuePair("userId", userId));
            params.add(new BasicNameValuePair("userName", userName));
            // 设置uri信息,并将参数集合放入uri;
            // 注:这里也支持一个键值对一个键值对地往里面放setParameter(String key, String value)
            uri = new URIBuilder().setScheme("http").setHost("localhost")
                    .setPort(8090).setPath("/user/get")
                    .setParameters(params).build();
        } catch (URISyntaxException e1) {
            e1.printStackTrace();
        }


        //2、 创建请求方法的实例,并指定请求URL
        HttpGet httpGet = new HttpGet(uri);

        //响应模型
        CloseableHttpResponse response = null;
        try {

            //添加配置信息
            RequestConfig requestConfig  = RequestConfig.custom()
                    //设置连接超时时间(单位毫秒)
                    .setConnectTimeout(5000)
                    //设置请求超时时间(单位毫秒)
                    .setConnectionRequestTimeout(5000)
                    //socket读写超时时间(单位毫秒)
                    .setSocketTimeout(50000)
                    //设置是否允许重定向(默认为true)
                    .setRedirectsEnabled(true).build();

            // 将上面的配置信息,添加到Get请求中
            httpGet.setConfig(requestConfig);

            // 由客户端执行发送Get请求
            response = httpClient.execute(httpGet);
            // 从响应模型中获取响应实体
            HttpEntity responseEntity = response.getEntity();
            System.out.println("响应状态为:" + response.getStatusLine());
            if (responseEntity != null) {
                System.out.println("响应内容长度为:" + responseEntity.getContentLength());
                System.out.println("响应内容为:" + EntityUtils.toString(responseEntity));
            }

        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (ParseException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                // 释放资源
                if (httpClient != null) {
                    httpClient.close();
                }
                if (response != null) {
                    response.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        3、POST请求 没有参数
         //1、创建HttpClient 客户端
        CloseableHttpClient httpClient = HttpClientBuilder.create().build();


        //2、 创建请求方法的实例,并指定请求URL
        HttpPost httpPost = new HttpPost("http://localhost:8090/user/get");

        //响应模型
        CloseableHttpResponse response = null;
        try {


            // 由客户端执行发送Post请求
            response = httpClient.execute(httpPost);
            // 从响应模型中获取响应实体
            HttpEntity responseEntity = response.getEntity();
            System.out.println("响应状态为:" + response.getStatusLine());
            if (responseEntity != null) {
                System.out.println("响应内容长度为:" + responseEntity.getContentLength());
                System.out.println("响应内容为:" + EntityUtils.toString(responseEntity));
            }

        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (ParseException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                // 释放资源
                if (httpClient != null) {
                    httpClient.close();
                }
                if (response != null) {
                    response.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        4、POST请求 有参(对象参数 或 路径参数)

        1)路径拼接参数

        String userId = "1";
        String userName = "张三";

        //1、创建HttpClient 客户端
        CloseableHttpClient httpClient = HttpClientBuilder.create().build();

        //参数 拼接
        StringBuffer params = new StringBuffer();
        try {
            // 字符数据最好encoding一下;这样一来,某些特殊字符才能传过去(如:某人的名字就是“&”,不encoding的话,传不过去)
            params.append("userId=" + URLEncoder.encode(userId, "utf-8"));
            params.append("&");
            params.append("userName="+ URLEncoder.encode(userName, "utf-8"));
        } catch (UnsupportedEncodingException e1) {
            e1.printStackTrace();
        }



        //2、 创建请求方法的实例,并指定请求URL
        HttpPost httpPost = new HttpPost("http://localhost:8090/user/get"+"?"+params);

        // 设置ContentType(注:一般路径拼接参数请求头都是application/x-www-form-urlencoded)
        httpPost.setHeader("Content-Type", "application/x-www-form-urlencoded");
        
        //响应模型
        CloseableHttpResponse response = null;
        try {

            //添加配置信息
            RequestConfig requestConfig  = RequestConfig.custom()
                    //设置连接超时时间(单位毫秒)
                    .setConnectTimeout(5000)
                    //设置请求超时时间(单位毫秒)
                    .setConnectionRequestTimeout(5000)
                    //socket读写超时时间(单位毫秒)
                    .setSocketTimeout(50000)
                    //设置是否允许重定向(默认为true)
                    .setRedirectsEnabled(true).build();

            // 将上面的配置信息,添加到Get请求中
            httpPost.setConfig(requestConfig);

            // 由客户端执行发送Get请求
            response = httpClient.execute(httpPost);
            // 从响应模型中获取响应实体
            HttpEntity responseEntity = response.getEntity();
            System.out.println("响应状态为:" + response.getStatusLine());
            if (responseEntity != null) {
                System.out.println("响应内容长度为:" + responseEntity.getContentLength());
                System.out.println("响应内容为:" + EntityUtils.toString(responseEntity));
            }

        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (ParseException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                // 释放资源
                if (httpClient != null) {
                    httpClient.close();
                }
                if (response != null) {
                    response.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        2)对象参数


        //1、创建HttpClient 客户端
        CloseableHttpClient httpClient = HttpClientBuilder.create().build();

        //2、 创建请求方法的实例,并指定请求URL
        HttpPost httpPost = new HttpPost("http://localhost:8090/user/get");

        User user = new User();
        user.setId(1L);
        user.setName("张三");
        // 我这里利用阿里的fastjson,将Object转换为json字符串;
        // (需要导入com.alibaba.fastjson.JSON包)
        String jsonString = JSON.toJSONString(user);

        // post请求是将参数放在请求体里面传过去的;这里将entity放入post请求体中
        StringEntity entity = new StringEntity(jsonString, "UTF-8");
        httpPost.setEntity(entity);
        // json参数需要设置请求头为 application/json
        httpPost.setHeader("Content-Type", "application/json;charset=utf8");

        //响应模型
        CloseableHttpResponse response = null;
        try {

            //添加配置信息
            RequestConfig requestConfig  = RequestConfig.custom()
                    //设置连接超时时间(单位毫秒)
                    .setConnectTimeout(5000)
                    //设置请求超时时间(单位毫秒)
                    .setConnectionRequestTimeout(5000)
                    //socket读写超时时间(单位毫秒)
                    .setSocketTimeout(50000)
                    //设置是否允许重定向(默认为true)
                    .setRedirectsEnabled(true).build();

            // 将上面的配置信息,添加到Get请求中
            httpPost.setConfig(requestConfig);

            // 由客户端执行发送Get请求
            response = httpClient.execute(httpPost);
            // 从响应模型中获取响应实体
            HttpEntity responseEntity = response.getEntity();
            System.out.println("响应状态为:" + response.getStatusLine());
            if (responseEntity != null) {
                System.out.println("响应内容长度为:" + responseEntity.getContentLength());
                System.out.println("响应内容为:" + EntityUtils.toString(responseEntity));
            }

        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (ParseException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                // 释放资源
                if (httpClient != null) {
                    httpClient.close();
                }
                if (response != null) {
                    response.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        3)(普通参数 + 对象参数)


        String userId = "1";
        String userName = "张三";

        //1、创建HttpClient 客户端
        CloseableHttpClient httpClient = HttpClientBuilder.create().build();


        //参数 拼接
        StringBuffer params = new StringBuffer();
        try {
            // 字符数据最好encoding一下;这样一来,某些特殊字符才能传过去(如:某人的名字就是“&”,不encoding的话,传不过去)
            params.append("userId=" + URLEncoder.encode(userId, "utf-8"));
            params.append("&");
            params.append("userName="+ URLEncoder.encode(userName, "utf-8"));
        } catch (UnsupportedEncodingException e1) {
            e1.printStackTrace();
        }



        //2、 创建请求方法的实例,并指定请求URL
        HttpPost httpPost = new HttpPost("http://localhost:8090/user/get"+"?"+params);

        User user = new User();
        user.setId(1L);
        user.setName("张三");
        // 我这里利用阿里的fastjson,将Object转换为json字符串;
        // (需要导入com.alibaba.fastjson.JSON包)
        String jsonString = JSON.toJSONString(user);

        // post请求是将参数放在请求体里面传过去的;这里将entity放入post请求体中
        StringEntity entity = new StringEntity(jsonString, "UTF-8");
        httpPost.setEntity(entity);
        // json参数需要设置请求头为 application/json
        httpPost.setHeader("Content-Type", "application/json;charset=utf8");

        //响应模型
        CloseableHttpResponse response = null;
        try {

            //添加配置信息
            RequestConfig requestConfig  = RequestConfig.custom()
                    //设置连接超时时间(单位毫秒)
                    .setConnectTimeout(5000)
                    //设置请求超时时间(单位毫秒)
                    .setConnectionRequestTimeout(5000)
                    //socket读写超时时间(单位毫秒)
                    .setSocketTimeout(50000)
                    //设置是否允许重定向(默认为true)
                    .setRedirectsEnabled(true).build();

            // 将上面的配置信息,添加到Get请求中
            httpPost.setConfig(requestConfig);

            // 由客户端执行发送Get请求
            response = httpClient.execute(httpPost);
            // 从响应模型中获取响应实体
            HttpEntity responseEntity = response.getEntity();
            System.out.println("响应状态为:" + response.getStatusLine());
            if (responseEntity != null) {
                System.out.println("响应内容长度为:" + responseEntity.getContentLength());
                System.out.println("响应内容为:" + EntityUtils.toString(responseEntity));
            }

        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (ParseException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                // 释放资源
                if (httpClient != null) {
                    httpClient.close();
                }
                if (response != null) {
                    response.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        

        5、使用httpClient下载文件

        使用httpclient下载文件,其实在调用上跟上面没有区别,唯一需要注意的是,再获取响应实体时,容易出现 Attempted read from closed stream尝试读取关闭的流 异常,我们可以用BufferedHttpEntity 的方式获取流:


        //1、创建HttpClient 客户端
        CloseableHttpClient httpClient = HttpClientBuilder.create().build();

        //2、 创建请求方法的实例,并指定请求URL
        HttpPost httpPost = new HttpPost("http://localhost:8090/user/get");

        //响应模型
        CloseableHttpResponse response = null;
        try {

            //添加配置信息
            RequestConfig requestConfig  = RequestConfig.custom()
                    //设置连接超时时间(单位毫秒)
                    .setConnectTimeout(5000)
                    //设置请求超时时间(单位毫秒)
                    .setConnectionRequestTimeout(5000)
                    //socket读写超时时间(单位毫秒)
                    .setSocketTimeout(50000)
                    //设置是否允许重定向(默认为true)
                    .setRedirectsEnabled(true).build();

            // 将上面的配置信息,添加到Get请求中
            httpPost.setConfig(requestConfig);

            // 由客户端执行发送Get请求
            response = httpClient.execute(httpPost);
            // 从响应模型中获取响应实体
            HttpEntity responseEntity = response.getEntity();
            //entity实体流保存缓冲区,否则只能操作一次流就会关闭 ,BufferedHttpEntity可以多次读取流
            responseEntity = new BufferedHttpEntity(responseEntity);
            System.out.println("响应状态为:" + response.getStatusLine());
            if (responseEntity != null) {
                System.out.println("响应内容长度为:" + responseEntity.getContentLength());
                System.out.println("响应内容为:" + EntityUtils.toString(responseEntity));
                try(FileOutputStream fileOutputStream = new FileOutputStream("C:\\Users\\Administrator\\Desktop\\新建文件夹 (2)\\测试.docx")){
                    responseEntity.writeTo(fileOutputStream);
                }
            }

        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (ParseException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                // 释放资源
                if (httpClient != null) {
                    httpClient.close();
                }
                if (response != null) {
                    response.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        6、关于https的调用

        目前还没使用到,等使用到再补充。

四、HttpClient连接池

        事实上对于httpClient 连接池以及相关的配置大有学问,针对高并发的场景有很多解决策略,这里只先简单介绍一下如何配置连接池以及怎么使用,复杂的业务范围可自行查询。

   HttpClient连接池是用于优化HTTP请求性能的一个关键机制,特别是在处理大量HTTP请求时,通过重用现有连接来减少每次新建连接的开销。连接池的主要优势包括减少建立连接的时间、减少资源消耗、提高请求的并发处理能力。

        以下是HttpClient连接池的几个核心概念和配置:

        

        1. 连接池的作用

        每次HTTP请求都需要进行TCP握手,特别是对于HTTPS,还需要进行TLS握手,这个过程非常耗时。连接池通过复用连接(连接保持在一个"池"中)避免了为每次请求都新建连接,从而大大提高性能。

        2、配置HttpClient连接池

        在Apache HttpClient中,可以通过PoolingHttpClientConnectionManager类来配置连接池。以下是一个基本的配置示例:

// 创建连接池管理器
PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
// 设置最大连接数
cm.setMaxTotal(100);
// 设置每个路由的最大连接数
cm.setDefaultMaxPerRoute(20);
// 创建HttpClient实例
CloseableHttpClient client = HttpClients.custom()
   .setConnectionManager(connectionManager)
   .setConnectionManagerShared(true)
   .evictIdleConnections(30, TimeUnit.SECONDS)  // 超过30秒的闲置连接会被清除
   .build();

最大连接数(MaxTotal): 池中允许的最大连接数。默认值较小,通常需要根据实际情况调大。

每个路由的最大连接数(DefaultMaxPerRoute): 每个目标主机(路由)允许的最大并发连接数。不同的主机或API服务器通常会有各自的并发限制。

保持连接活动时间(ConnectionKeepAlive): 指定一个连接在闲置后可以保持多久。短时间的保活可以避免不必要的重建连接,但太长时间可能导致连接闲置过多,浪费资源。

        注意事项

  • 连接泄漏: 如果不正确管理连接(如未关闭),可能会导致连接泄漏,从而耗尽连接池中的可用连接,影响系统的稳定性。
  • 线程安全: PoolingHttpClientConnectionManager是线程安全的,可以在多个线程中共享同一个HttpClient实例。

高并发场景下的 HttpClient 优化方案,QPS 大大提升!


http://www.kler.cn/news/305868.html

相关文章:

  • 一文带你全面了解RAID技术:从基础到进阶的全景解析
  • 大厂硬件梦:字节、腾讯“向首”,华为、小米“向手”
  • 设计模式之建造者模式(通俗易懂--代码辅助理解【Java版】)
  • MSYS vs MSYS2:功能、兼容性与易用性全面比拼,助你挑选最佳Windows开发伴侣
  • SpringBoot集成Thymeleaf模板引擎,为什么使用(详细介绍)
  • 【CSS in Depth 2 精译_031】5.3 Grid 网格布局的两种替代语法
  • TCP Analysis Flags 之 TCP ZeroWindow
  • 【机器学习】7 ——k近邻算法
  • npm install报错,gyp verb `which` failed Error: not found: python
  • 第十六节:学习Springboot 的自定义资源路径(自学Spring boot 3.x的第四天)
  • 鸿蒙之Hello Word 遇坑总结 mac系统 不能预览 提示 Only files in a module can be previewed 解决办法
  • [Mdp] lc3290. 最高乘法得分(二维dp+状态定义+状态转移+LCS问题+好题+周赛415_2)
  • 网络原理(3)—— 应用层、传输层(TCP)
  • ArcGIS Pro SDK (十三)地图创作 4 设备
  • Qt 学习第十天:标准对话框 页面布局
  • Windows11 WSL2的ubuntu 22.04中拉取镜像报错
  • 分贝转换 1 mVpp = 9.03dBmV
  • 【软考】设计模式之抽象工厂模式
  • Linux通配符*、man 、cp、mv、echo、cat、more、less、head、tail、等指令、管道 | 、指令的本质 等的介绍
  • 重修设计模式-创建型-建造者模式
  • 基于YOLOv8的遥感光伏板检测系统
  • Vite + Electron 时,Electron 渲染空白,静态资源加载错误等问题解决
  • mysql的监控指标采集
  • 机器学习-------数据标准化
  • 一键生成中秋国风插画!FLUX中秋专属Lora的使用教程
  • 随着Batch size增加,最佳learning rate如何选择?
  • 一个关于Excel的段子
  • 2860. 让所有学生保持开心的分组方法数
  • 模板替换引擎(支持富文本动态表格)
  • 物体识别之微特征识别任务综述