基于nginx 动态 URL反向代理的实现

背景:

        我们在项目中在这样一个场景,用户需要使用固定的软件资源,这些资源是以服务器或者以容器形式存在的。

        资源以webAPI方式在内网向外提供接口,资源分类多种类型,每种类型的资源程序和Wapi参数都一样。这些资源部属完成后使用IP+端口进行区分。如下表所示

     

技术分析:

经过调研分析,发现Nginx 可以进行么向代理,代理后可以进行调度到内部的数据

技术验证:

1.使用静态方式在配置文件中直接写入

如下:

server {
        listen        22280;
        server_name  localhost;
        root   "D:/dist";
        location / {
            index index.php index.html error/index.html;
            error_page 400 /error/400.html;
            error_page 403 /error/403.html;
            error_page 404 /error/404.html;
            error_page 500 /error/500.html;
            error_page 501 /error/501.html;
            error_page 502 /error/502.html;
            error_page 503 /error/503.html;
            error_page 504 /error/504.html;
            error_page 505 /error/505.html;
            error_page 506 /error/506.html;
            error_page 507 /error/507.html;
            error_page 509 /error/509.html;
            error_page 510 /error/510.html;
            #include D:/Git/111/nginx.htaccess;
            autoindex  off;
			try_files $uri $uri/ @router; #需要指向下面的@router否则会出现vue的路由在nginx中刷新出现404
			index  index.html index.htm;
        }
		#反向代理 
		location /r1/ {     
			proxy_pass http://192.168.1.88:888/;            
        }
				location /r2/ {     
			proxy_pass http://192.168.1.88:887/;            
        }
				location /i1/ {     
			proxy_pass http://192.168.1.89:3333/;            
        }
				location /i2/ {     
			proxy_pass http://192.168.1.90:3333/;            
        }
 
  #对应上面的@router,主要原因是路由的路径资源并不是一个真实的路径,所以无法找到具体的文件
  #因此需要rewrite到index.html中,然后交给路由在处理请求资源
		location @router {
				rewrite ^.*$ /index.html last;
			}
        location ~ \.php(.*)$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  PATH_INFO  $fastcgi_path_info;
            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
            include        fastcgi_params;
        }
}

使用此方式可以达到所需效果,但如果资源变化需要手动调整Nginx的配置文件。因此考虑有没有一种办法可以做到动态转发呢?

问题难点:

1.资源需要一定的规律性

2.nginx动态转发功能技术上需要进行预研,明确是否可行

实现过程:

1.确定方案

方案里我们准备采用 固定内容+端口号的形式来进行处理,在此之前我们需要把服务用K8S映射到

同一IP或者同一规则的内容上。并且对URL进行了定义 /rs/(\d+)/实际API  的形式进行调用

2.方案实现

我们假定所有的 k8s 把所有的服务地址都映射到了 192.168.1.88上,仅端口不同,使用不同的端口就可以调度到不同的服务。

部分配置如下:

		location /rs/(\d.+)/ {     
			proxy_pass http://localhost:$/;            
        }

运行报错 http 500

500 Internal Server Error
nginx/1.15.11
问题处理:
2024/03/22 17:07:35 [error] 5072#34752: *264 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "127.0.0.1:280"
2024/03/22 17:07:35 [error] 5072#34752: *265 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "127.0.0.1:280"
2024/03/22 17:08:15 [error] 5072#34752: *268 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "127.0.0.1:280"
2024/03/22 17:08:16 [error] 5072#34752: *269 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "127.0.0.1:280"
2024/03/22 17:08:16 [error] 5072#34752: *270 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "127.0.0.1:280"
2024/03/22 17:08:17 [error] 5072#34752: *271 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "127.0.0.1:280"
2024/03/22 17:09:24 [error] 5072#34752: *273 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "127.0.0.1:280"
2024/03/22 17:09:24 [error] 5072#34752: *274 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "127.0.0.1:280"
2024/03/22 17:09:25 [error] 5072#34752: *275 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "127.0.0.1:280"
2024/03/22 17:09:26 [error] 5072#34752: *276 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "127.0.0.1:280"
2024/03/22 17:09:27 [error] 5072#34752: *277 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "127.0.0.1:280"
2024/03/22 17:09:27 [error] 5072#34752: *278 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "127.0.0.1:280"
2024/03/22 17:09:35 [error] 5072#34752: *283 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "127.0.0.1:280"
2024/03/22 17:09:36 [error] 5072#34752: *284 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "127.0.0.1:280"
2024/03/22 17:09:36 [error] 5072#34752: *285 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "127.0.0.1:280"
2024/03/22 17:09:37 [error] 5072#34752: *286 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "127.0.0.1:280"
2024/03/22 17:09:38 [error] 5072#34752: *287 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "127.0.0.1:280"
2024/03/22 17:09:38 [error] 5072#34752: *288 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "127.0.0.1:280"
2024/03/22 17:10:00 [error] 5072#34752: *279 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "GET /uuu/60000/api/sysAuth/index.html HTTP/1.1", upstream: "http://192.168.27.51:60000/", host: "127.0.0.1:280"
2024/03/22 17:10:00 [error] 5072#34752: *279 rewrite or internal redirection cycle while processing "/index.html", client: 127.0.0.1, server: localhost, request: "GET /uuu/60000/api/sysAuth/index.html HTTP/1.1", upstream: "http://192.168.27.51:60000/", host: "127.0.0.1:280"
2024/03/22 17:10:01 [error] 5072#34752: *280 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "127.0.0.1:280", referrer: "http://127.0.0.1:280/uuu/60000/api/sysAuth/index.html"
2024/03/22 17:11:05 [error] 5072#34752: *290 upstream timed out (10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond) while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "GET /uuu/60000/api/sysAuth/index.html HTTP/1.1", upstream: "http://192.168.27.51:60000/", host: "127.0.0.1:280"
2024/03/22 17:11:05 [error] 5072#34752: *290 rewrite or internal redirection cycle while processing "/index.html", client: 127.0.0.1, server: localhost, request: "GET /uuu/60000/api/sysAuth/index.html HTTP/1.1", upstream: "http://192.168.27.51:60000/", host: "127.0.0.1:280"
2024/03/22 17:11:05 [error] 5072#34752: *293 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "127.0.0.1:280", referrer: "http://127.0.0.1:280/uuu/60000/api/sysAuth/index.html"
2024/03/22 17:14:18 [error] 8748#17732: *1 upstream timed out (10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond) while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "GET /uuu/60000/index.html HTTP/1.1", upstream: "http://192.168.27.51:60000/uuu/60000/index.html", host: "localhost:280"
2024/03/22 17:14:18 [error] 8748#17732: *1 rewrite or internal redirection cycle while processing "/index.html", client: 127.0.0.1, server: localhost, request: "GET /uuu/60000/index.html HTTP/1.1", upstream: "http://192.168.27.51:60000/uuu/60000/index.html", host: "localhost:280"
2024/03/22 17:14:19 [error] 8748#17732: *5 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "localhost:280", referrer: "http://localhost:280/uuu/60000/index.html"
2024/03/22 17:15:59 [error] 12116#31400: *4 upstream timed out (10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond) while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "GET /uuu/60000/aaaa HTTP/1.1", upstream: "http://192.168.27.51:60000/", host: "localhost:280"
2024/03/22 17:15:59 [error] 12116#31400: *4 rewrite or internal redirection cycle while processing "/index.html", client: 127.0.0.1, server: localhost, request: "GET /uuu/60000/aaaa HTTP/1.1", upstream: "http://192.168.27.51:60000/", host: "localhost:280"
2024/03/22 17:15:59 [error] 12116#31400: *7 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "localhost:280", referrer: "http://localhost:280/uuu/60000/aaaa"
2024/03/22 17:20:20 [error] 33904#20644: *1 upstream timed out (10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond) while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "GET /uuu/60000/api/sysAuth/captcha HTTP/1.1", upstream: "http://192.168.27.51:60000/", host: "localhost:280"
2024/03/22 17:20:20 [error] 33904#20644: *1 rewrite or internal redirection cycle while processing "/index.html", client: 127.0.0.1, server: localhost, request: "GET /uuu/60000/api/sysAuth/captcha HTTP/1.1", upstream: "http://192.168.27.51:60000/", host: "localhost:280"
2024/03/22 17:20:20 [error] 33904#20644: *4 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "localhost:280", referrer: "http://localhost:280/uuu/60000/api/sysAuth/captcha"
2024/03/22 17:24:31 [error] 41040#27804: *2 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "localhost:280", referrer: "http://localhost:280/uuu/5257/api/sysAuth/captcha"
2024/03/22 17:24:35 [error] 41040#27804: *4 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /_framework/aspnetcore-browser-refresh.js HTTP/1.1", host: "localhost:280", referrer: "http://localhost:280/uuu/5257/index.html"
2024/03/22 17:24:35 [error] 41040#27804: *11 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /index-mini-profiler/includes.min.js?v=4.3.8+1120572909 HTTP/1.1", host: "localhost:280", referrer: "http://localhost:280/uuu/5257/index.html"
2024/03/22 17:24:35 [error] 41040#27804: *12 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /_vs/browserLink HTTP/1.1", host: "localhost:280", referrer: "http://localhost:280/uuu/5257/index.html"
2024/03/22 17:24:35 [error] 41040#27804: *13 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /swagger/%E5%85%AC%E5%85%B1%E6%9C%8D%E5%8A%A1/swagger.json HTTP/1.1", host: "localhost:280", referrer: "http://localhost:280/uuu/5257/index.html"
2024/03/22 17:35:40 [error] 41512#41416: *8 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /_framework/aspnetcore-browser-refresh.js HTTP/1.1", host: "localhost:280", referrer: "http://localhost:280/area/5257/index.html"
2024/03/22 17:35:40 [error] 41512#41416: *10 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /_vs/browserLink HTTP/1.1", host: "localhost:280", referrer: "http://localhost:280/area/5257/index.html"
2024/03/22 17:35:40 [error] 41512#41416: *9 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /index-mini-profiler/includes.min.js?v=4.3.8+1120572909 HTTP/1.1", host: "localhost:280", referrer: "http://localhost:280/area/5257/index.html"
2024/03/22 17:35:40 [error] 41512#41416: *2 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /swagger/%E5%85%AC%E5%85%B1%E6%9C%8D%E5%8A%A1/swagger.json HTTP/1.1", host: "localhost:280", referrer: "http://localhost:280/area/5257/index.html"

通过日志发现存在循环引用之类的

考虑使用URL重写改变下,路径。再使用proxy_pass反向代理。尝试修改nginx并进行修改。

问题解决
location ~ ^/rs/(\d.+)/{
			rewrite ^/rs/(\d+)/(.*)$ /$2 break;
			proxy_pass http://192.168.1.88:$1;  
        }

最终结果能够正常转发到指定端口,并且nginx 也不用修改配置,实现了动态端口反向代理。

在这个过程中我发现要实现/dir/port/xxx 这种进行反向代理必须与url重写结合使用。不然会报404.

完整能够成功运行的配置nginx.conf如下

server {
        listen        22280;
        server_name  localhost;
        root   "D:/dist";
        location / {
            index index.php index.html error/index.html;
            error_page 400 /error/400.html;
            error_page 403 /error/403.html;
            error_page 404 /error/404.html;
            error_page 500 /error/500.html;
            error_page 501 /error/501.html;
            error_page 502 /error/502.html;
            error_page 503 /error/503.html;
            error_page 504 /error/504.html;
            error_page 505 /error/505.html;
            error_page 506 /error/506.html;
            error_page 507 /error/507.html;
            error_page 509 /error/509.html;
            error_page 510 /error/510.html;
            #include D:/Git/111/nginx.htaccess;
            autoindex  off;
			try_files $uri $uri/ @router; #需要指向下面的@router否则会出现vue的路由在nginx中刷新出现404
			index  index.html index.htm;
        }
		#反向代理 
		location ~ ^/rs/(\d.+)/{
			rewrite ^/rs/(\d+)/(.*)$ /$2 break;
			proxy_pass http://192.168.1.88:$1;  
        }
 
  #对应上面的@router,主要原因是路由的路径资源并不是一个真实的路径,所以无法找到具体的文件
  #因此需要rewrite到index.html中,然后交给路由在处理请求资源
		location @router {
				rewrite ^.*$ /index.html last;
			}
        location ~ \.php(.*)$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  PATH_INFO  $fastcgi_path_info;
            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
            include        fastcgi_params;
        }
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/489469.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

javaWeb在线考试系统

一、简介 在线考试系统是现代教育中一项重要的辅助教学工具,它为学生提供了便捷的考试方式,同时也为教师提供了高效的考试管理方式。我设计了一个基于JavaWeb的在线考试系统,该系统包括三个角色:管理员、老师和学生。管理员拥有菜…

ubuntu2004自动更新内核导致nvidia驱动无法正常启动的问题

症状 开机后,nvidia-smi无法正常显示显卡状态,另外无法连接多个显示屏 解决 参考这个文章: ls /usr/src可以看到已安装的nvidia驱动版本是nvidia-535.54.03 然后运行下面的指令: sudo apt-get install dkmssudo dkms instal…

Mimikatz介绍

一、Mimikatz定义 mimikatz是benjamin使用C语言编写的一款非常强大的安全工具,它可以从机器内存中提取明文密码、密码Hash、PIN码和Kerberos票据等。它的功能非常强大,得到全球安全研究员的广泛使用。 Mimikatz 是一款功能强大的轻量级调试神器&#xff…

Java版直播商城免 费 搭 建:平台规划与常见营销模式,电商源码、小程序、三级分销及详解

【saas云平台】打造全行业全渠道全场景的saas产品,为经营场景提供一体化解决方案;门店经营区域化、网店经营一体化,本地化、全方位、一站式服务,为多门店提供统一运营解决方案;提供丰富多样的营销玩法覆盖所有经营场景…

在vue中使用echarts饼图示例

1.安装 npm install echarts --save 2.官方示例 option {title: {text: Referer of a Website,subtext: Fake Data,left: center},tooltip: {trigger: item},legend: {orient: vertical,left: left},series: [{name: Access From,type: pie,radius: 50%,data: [{ value: 104…

巧用cpl文件维权和免杀(下)

cpl文件的应用 bypass Windows AppLocker 什么是Windows AppLocker: AppLocker即“应用程序控制策略”,是Windows 7系统中新增加的一项安全功能。在win7以上的系统中默认都集成了该功能。 默认的Applocker规则集合,可以看到cpl并不在默认规则中: 开启Applocker规…

NVIDIA NIM 提供优化的推理微服务以大规模部署 AI 模型

NVIDIA NIM 提供优化的推理微服务以大规模部署 AI 模型 生成式人工智能的采用率显着上升。 在 2022 年 OpenAI ChatGPT 推出的推动下,这项新技术在几个月内就积累了超过 1 亿用户,并推动了几乎所有行业的开发活动激增。 到 2023 年,开发人员…

聊一聊常见的网络安全模型

目录 一、概述 二、基于时间的PDR模型 2.1 模型概念提出者 2.2 模型图 2.3 模型内容 2.3.1 Protection(保护) 2.3.2 Detection(检测) 2.3.3 Response(响应) 2.4 PDR模型思想 2.4.1 PDR模型假设 2…

【k8s】kubeasz 3.6.3 + virtualbox 搭建本地虚拟机openeuler 22.03 三节点集群 离线方案

kubeasz项目源码地址 GitHub - easzlab/kubeasz: 使用Ansible脚本安装K8S集群,介绍组件交互原理,方便直接,不受国内网络环境影响 拉取代码,并切换到最近发布的分支 git clone https://github.com/easzlab/kubeasz cd kubeasz gi…

【openGL4.x手册10】基元程序集和面部剔除

https://www.khronos.org/opengl/wiki/Face_Culling 一、说明 基元汇编是 OpenGL 渲染管道中的阶段,在该阶段,基元被划分为一系列单独的基本基元。经过一些小的处理后,如下所述,它们被传递到光栅器进行渲染。 二 早期原始组装 基…

Spring实例化Bean的三种方式

参考资料: Core Technologies 核心技术 spring实例化bean的三种方式 构造器来实例化bean 静态工厂方法实例化bean 非静态工厂方法实例化bean_spring中有参构造器实例化-CSDN博客 1. 构造函数 1.1. 空参构造函数 下面这样表示调用空参构造函数,使用p…

npm ERR! cb() never called!(已解决)

从仓库拉下来的代码,用npm install时报错 试了很多种方法,结果发现有一种可能是你的node版本过低导致的,可以升级node版本试一下。 node版本升级后,把上一次npm install错误的node_modules删除,重新npm install。

压力测试面试题及答案!

压力测试是软件测试中的一种测试方式,用于评估软件系统在各种压力条件下的性能表现。以下是常见的压力测试面试题及答案: 什么是压力测试? 压力测试是一种测试方式,用于模拟实际用户在正常和峰值负载条件下对软件系统施加的压力&…

java线程池原理浅析

问题与解决: 问题: 查询大数据量的时候,例如一次返回50w数据量的包,循环去查询发现读取会超时。 解决方案: 经过思考采用多线程去分页查询。使用线程池创建多个线程去查询分页后的数据最后汇总一下,解决…

双指针算法_盛水最多的容器

题目: 题目解析: 如图所示,一个数组内部存储的是高度,求数组中,能够组成最大容量的两个元素,需要注意的是容量是 高度*宽度,这里的宽度指的是两个数字之间的距离,且需要注意高度中&…

现代c++内存管理的方式有哪些?

在现代C编程实践中,内存管理是软件开发中的核心议题之一,直接影响着程序的性能、稳定性以及资源的有效利用。C提供了一系列丰富且灵活的内存管理机制,以适应不同场景的需求和应对潜在的内存问题,如内存泄漏、野指针和堆栈溢出等。…

VUE之首次加载项目缓慢

最近公司有个大型的项目,使用vue2开发的,但是最终开发完成之后,项目发布到线上,首次加载项目特别缓慢,有时候至少三十秒才能加载完成,加载太慢了,太影响用户体验了,最近研究了一下优…

java spirng和 mybatis 常用的注解有哪些

当在Java Spring和MyBatis中进行开发时,常用的注解对于简化配置和提高开发效率非常重要。以下是更多常用的注解以及它们的详细说明和用途: 在Spring中常用的注解: Component: 用途:表明一个类会作为组件被Spring容器管…

AJAX(一):初识AJAX、http协议、配置环境、发送AJAX请求、请求时的问题

一、什么是AJAX 1.AJAX 就是异步的JS和XML。通过AJAX 可以在浏览器中向服务器发送异步请求,最大的优势:无刷新获取数据。AJAX 不是新的编程语言,而是一种将现有的标准组合在一起使用的新方式。 2.XML 可扩展标记语言。XML被设计用来传输和…

C++(13) STL 库初识

文章目录 STL 库初识1. STL 库1.1 STL 库的案例1.2 C 标准模板库的三个组件1.3 案例展示 2. 迭代器1.1 概述和分类2.2 代码案例 STL 库初识 1. STL 库 1.1 STL 库的案例 类似学习了模板的概念。CSTL (标准模板库) 是一套功能强大的 C 模板类,提供了通用的模板类和…