J2EE征程——第一个纯servletCURD

第一个纯servletCURD

  • 前言
    • 在此之前
  • 一,概述
  • 二、CURD
    • 1介绍
    • 2查询并列表显示
      • 准备实体类country
      • 编写 CountryListServlet
      • 配置web.xml
      • 为web应用导入mysql-jdbc的jar包
    • 3增加
      • 准备增加的页面addc.html
      • 编写 CAddServlet
      • 配置web.xml
      • 测试
    • 4删除
      • 修改CountryListServlet(提供delete超链)
      • 编写CDeleteServlet
      • 配置web.xml
    • 5修改
      • 修改CountryListServlet (提供edit超链)
      • 准备CEditServlet(获取历史数据)
      • 准备CUpdateServlet(修改数据)
      • 配置web.xml
  • 三,总结

前言

很久以前便决定学习java了,那个时候还不知道J2EE到底是什么。逐渐地走了很远,才发现曾经遇到的、复现的java网站和赛题都只是一知半解。现如今总算是半只脚迈入了javaweb的大门,将成果分享一下,以供后来者参考。
注意:纯servlet项目和jsp项目有一定区别,后续学习若有成果会再次分享。

在此之前

说在前面,想要掌握CURD的基本知识需要一定基础,有关java的集合框架;servlet的部署、调用、request(response)方法;eclipse部署等要有一定了解(相信参考这篇文章学习的你已经掌握了上述知识)。

一,概述

Java2平台包括:标准版(J2SE)、企业版(J2EE)和微缩版(J2ME)三个版。
J2EE是简而言之,j2EE是一种网站开发标准或者说接口。

二、CURD

备注:表格结构
在这里插入图片描述mysql安装的示例类。这里把city和countrylanguage的外键都删除了,然后为country表新增了一个id列,保留了Name、SurfaceArea、Population这三个字段(String,int,float各一个),其他全部删除。
在这里插入图片描述

1介绍

CRUD是常见的页面功能,即我们常说的增删改查
C - Creation 增加
R - Retrieve 查询
U - Update 修改
D - DELETE 删除

备注:实体类一般定义在bean包中,DAO类一般定义在dao包中,Servlet一般定义在servlet包中,便于管理。

2查询并列表显示

准备实体类country

country表有Code、Name、Continent、Region、SurfaceArea、IndepYear、Population、LifeExpectancy、GNP、GNPOld、LocalName、GovernmentForm、HeadOfState、Capital、Code2等列名。
选择name、surfacearea、population三个(string、float、int各一个)作为country类的属性
并且为每一个属性提供public的getter和setter。

package world;
public class country {public int id;public String name;public float surfacearea;public int population;public int getId() {return id;}public void setId(int id) {this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}public float getsurfacearea() {return surfacearea;}public void setsurfacearea(float surfacearea) {this.surfacearea = surfacearea;}public int getpopulation() {return population;}public void setpopulation(int population) {this.population = population;}}

准备一个CountryDAO,提供增加,删除,修改,查询等常规数据库操作方法
注意,查表的结果与字段顺序有关,若表结构更换,以下获取字段的序号都要更换。

package world;import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;import world.country;public class countrydao {public countrydao() {try {Class.forName("com.mysql.jdbc.Driver");} catch (ClassNotFoundException e) {e.printStackTrace();}}public Connection getConnection() throws SQLException {return DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/world?characterEncoding=UTF-8", "root","123456");}public int getTotal() {int total = 0;try (Connection c = getConnection(); Statement s = c.createStatement();) {String sql = "select count(*) from country";ResultSet rs = s.executeQuery(sql);while (rs.next()) {total = rs.getInt(1);}System.out.println("total:" + total);} catch (SQLException e) {e.printStackTrace();}return total;}public void add(country country) {String sql = "insert into country values(null,?,?,?)";try (Connection c = getConnection(); PreparedStatement ps = c.prepareStatement(sql);) {ps.setString(1, country.name);ps.setFloat(2, country.surfacearea);ps.setInt(3, country.population);ps.execute();ResultSet rs = ps.getGeneratedKeys();if (rs.next()) {int id = rs.getInt(1);country.id = id;}} catch (SQLException e) {e.printStackTrace();}}public void update(country country) {String sql = "update country set name= ?, surfacearea = ? , population = ? where id = ?";try (Connection c = getConnection(); PreparedStatement ps = c.prepareStatement(sql);) {ps.setString(1, country.name);ps.setFloat(2, country.surfacearea);ps.setInt(3, country.population);ps.setInt(4, country.id);ps.execute();} catch (SQLException e) {e.printStackTrace();}}public void delete(int id) {try (Connection c = getConnection(); Statement s = c.createStatement();) {String sql = "delete from country where id = " + id;s.execute(sql);} catch (SQLException e) {e.printStackTrace();}}public country get(int id) {//返回值为country类的get方法country country = null;try (Connection c = getConnection(); Statement s = c.createStatement();) {String sql = "select * from country where id = " + id;ResultSet rs = s.executeQuery(sql);if (rs.next()) {country = new country();String name = rs.getString(2);//获取表的第3个列名float surfacearea = rs.getFloat("surfacearea");int population = rs.getInt(4);//获取表的第8个列名country.name = name;country.surfacearea = surfacearea;country.population = population;country.id = id;}} catch (SQLException e) {e.printStackTrace();}return country;}public List<country> list() {return list(0, Short.MAX_VALUE);}public List<country> list(int start, int count) {List<country> countries = new ArrayList<country>();String sql = "select * from country order by id desc limit ?,? ";try (Connection c = getConnection(); PreparedStatement ps = c.prepareStatement(sql);) {ps.setInt(1, start);ps.setInt(2, count);ResultSet rs = ps.executeQuery();while (rs.next()) {country country = new country();int id = rs.getInt(1);String name = rs.getString(2);float surfacearea = rs.getFloat("surfacearea");int population = rs.getInt(4);country.id = id;country.name = name;country.surfacearea = surfacearea;country.population = population;countries.add(country);}} catch (SQLException e) {e.printStackTrace();}return countries;}}

编写 CountryListServlet

做一个Country的维护页面需要一些通用的操作,比如增加,删除,编辑,修改,查询等。
每个不同的操作,都需要一个对应的Servlet,除了做Country之外,还会做到其他的一些表的相关操作,所以好的规范会对将来的维护更有好处。
一般会这样命名,以查询为例 CountryListServlet : [表][行为]Servlet 这样一种命名规则。
所以对于Country而言就会如此命名:
增加 CountryAddServlet
删除 CountryDeleteServlet
编辑 CountryEditServlet
修改 CountryUpdateServlet
查询 CountryListServlet
在CountryListServlet中,会使用CountryDAO把数据查询出来,然后拼接成一个table用于显示其内容

package world;import java.io.IOException;
import java.util.List;import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;import world.country;
import world.countrydao;public class CountryListServlet extends HttpServlet {protected void service(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {response.setContentType("text/html; charset=UTF-8");List<country> countries = new countrydao().list();StringBuffer sb = new StringBuffer();sb.append("<table align='center' border='1' cellspacing='0'>\r\n");sb.append("<tr><td>id</td><td>name</td><td>surfacearea</td><td>population</td></tr>\r\n");String trFormat = "<tr><td>%d</td><td>%s</td><td>%f</td><td>%d</td></tr>\r\n";for (country country : countries) {String tr = String.format(trFormat, country.getId(), country.getName(), country.getsurfacearea(), country.getpopulation());sb.append(tr);}sb.append("</table>");response.getWriter().write(sb.toString());}
}

配置web.xml

在web.xml中把路径 listHero映射到HeroListServlet上。

<?xml version="1.0" encoding="UTF-8"?>
<web-app><servlet><servlet-name>HelloServlet</servlet-name><servlet-class>HelloServlet</servlet-class><load-on-startup>10</load-on-startup></servlet><servlet-mapping><servlet-name>HelloServlet</servlet-name><url-pattern>/hello</url-pattern></servlet-mapping><servlet><servlet-name>LoginServlet</servlet-name><servlet-class>LoginServlet</servlet-class></servlet><servlet-mapping><servlet-name>LoginServlet</servlet-name><url-pattern>/login</url-pattern></servlet-mapping>   <servlet><servlet-name>RegisterServlet</servlet-name><servlet-class>RegisterServlet</servlet-class></servlet><servlet-mapping><servlet-name>RegisterServlet</servlet-name><url-pattern>/register</url-pattern></servlet-mapping><servlet><servlet-name>CountryListServlet</servlet-name><servlet-class>world.CountryListServlet</servlet-class></servlet><servlet-mapping><servlet-name>CountryListServlet</servlet-name><url-pattern>/listc</url-pattern></servlet-mapping>   </web-app>

为web应用导入mysql-jdbc的jar包

把 mysql 的jar包放在WEB-INF/lib 目录下
放在WEB-INF/lib 下指的是能够web应用中找到对应的class,如果要在eclipse中做调试,还是需要为项目添加该jar才可以。

3增加

准备增加的页面addc.html

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

表示用UTF-8显示中文,同时浏览器也会使用UTF-8编码提交中文
form:
action设置为addHero路径
method设置为post 也是为了提交中文
在web目录下添加

<!DOCTYPE html><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><form action="addc" method="post">国家名称 : <input type="text" name="name"> <br>国土面积: <input type="text" name="surfacearea"> <br>人口数量: <input type="text" name="population"> <br><input type="submit" value="增加 ">
</form>

在这里插入图片描述

编写 CAddServlet

HeroAddServlet 中根据浏览器传过来的参数,创建一个Hero对象。 接着通过HeroDAO把该对象保存到数据库中。
最后使用客户端跳转到listHero查看所有的Hero,就能看到新加入的Hero对象了
request.setCharacterEncoding(“UTF-8”);
表示使用UTF-8的方式获取浏览器传过来的中文

package world;import java.io.IOException;import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;import world.country;
import world.countrydao;public class CAddServlet extends HttpServlet {protected void service(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {request.setCharacterEncoding("UTF-8");country country = new country();country.setName(request.getParameter("name"));country.setsurfacearea(Float.parseFloat(request.getParameter("surfacearea")));country.setpopulation(Integer.parseInt(request.getParameter("population")));new countrydao().add(country);response.sendRedirect("/j2ee/listc");}
}

配置web.xml

    <servlet><servlet-name>HeroAddServlet</servlet-name><servlet-class>servlet.HeroAddServlet</servlet-class></servlet><servlet-mapping><servlet-name>HeroAddServlet</servlet-name><url-pattern>/addHero</url-pattern></servlet-mapping>    

测试

重启tomcat,访问增加页面http://127.0.0.1/addc.html
提交数据,接着客户端跳转到/j2ee/lisc,就可以显示新增加的这条数据了
在这里插入图片描述

4删除

修改CountryListServlet(提供delete超链)

修改CountryListServlet,多一个单元格,是一个超链
超链的href属性指向地址 /deleteC?id=242(每条不同的记录id不一样)
可以在左下角的浏览器状态栏里看到

package world;import java.io.IOException;
import java.util.List;import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;import world.country;
import world.countrydao;public class CountryListServlet extends HttpServlet {protected void service(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {response.setContentType("text/html; charset=UTF-8");List<country> countries = new countrydao().list();StringBuffer sb = new StringBuffer();sb.append("<table align='center' border='1' cellspacing='0'>\r\n");sb.append("<tr><td>id</td><td>name</td><td>surfacearea</td><td>population</td><td>delete</td></tr>\r\n");String trFormat = "<tr><td>%d</td><td>%s</td><td>%f</td><td>%d</td><td><a href='deletec?id=%d'>delete</a></td></tr>\r\n";for (country country : countries) {String tr = String.format(trFormat, country.getId(), country.getName(), country.getsurfacearea(), country.getpopulation(), country.getId());sb.append(tr);}sb.append("</table>");response.getWriter().write(sb.toString());}
}

在这里插入图片描述

编写CDeleteServlet

首先获取参数id
然后通过countrydao根据id,删除该对象
然后客户端跳转到 /listc

package world;import java.io.IOException;import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;import world.country;public class CDeleteServlet extends HttpServlet {protected void service(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {int id = Integer.parseInt(request.getParameter("id"));new countrydao().delete(id);response.sendRedirect("/j2ee/listc");}
}

配置web.xml

把/deletec指向CDeleteServlet

<servlet><servlet-name>CDeleteServlet</servlet-name><servlet-class>world.CDeleteServlet</servlet-class></servlet><servlet-mapping><servlet-name>CDeleteServlet</servlet-name><url-pattern>/deletec</url-pattern></servlet-mapping>    

在这里插入图片描述

5修改

修改CountryListServlet (提供edit超链)

新增加一列 edit,里面放上指向 /edit的超链

package world;import java.io.IOException;
import java.util.List;import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;import world.country;
import world.countrydao;public class CountryListServlet extends HttpServlet {protected void service(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {response.setContentType("text/html; charset=UTF-8");List<country> countries = new countrydao().list();StringBuffer sb = new StringBuffer();sb.append("<table align='center' border='1' cellspacing='0'>\r\n");sb.append("<tr><td>id</td><td>name</td><td>surfacearea</td><td>population</td><td>edit</td><td>delete</td></tr>\r\n");String trFormat = "<tr><td>%d</td><td>%s</td><td>%f</td><td>%d</td><td><a href='edit?id=%d'>edit</a></td><td><a href='deletec?id=%d'>delete</a></td></tr>\r\n";for (country country : countries) {String tr = String.format(trFormat, country.getId(), country.getName(), country.getsurfacearea(), country.getpopulation(), country.getId(), country.getId());sb.append(tr);}sb.append("</table>");response.getWriter().write(sb.toString());}
}

在这里插入图片描述

准备CEditServlet(获取历史数据)

CEditServlet 根据浏览器传过来的id获取一个country对象
然后根据这个对象,准备一个类似add.html的页面,不同之处在于每个输入框都是有值的。
最后还会提供一个type="hidden"的input,用于提交id到路径/update

package world;import java.io.IOException;import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;import world.country;
import world.countrydao;public class CEditServlet extends HttpServlet {protected void service(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {int id = Integer.parseInt(request.getParameter("id"));country country = new countrydao().get(id);StringBuffer format = new StringBuffer();response.setContentType("text/html; charset=UTF-8");format.append("<!DOCTYPE html>");format.append("<form action='update' method='post'>");format.append("国家名称: <input type='text' name='name' value='%s' > <br>");format.append("国土面积: <input type='text' name='surfacearea'  value='%f' > <br>");format.append("人口数量: <input type='text' name='population'  value='%d' > <br>");format.append("<input type='hidden' name='id' value='%d'>");format.append("<input type='submit' value='更新'>");format.append("</form>");String html = String.format(format.toString(), country.getName(), country.getsurfacearea(), country.getpopulation(), country.getId());response.getWriter().write(html);}
}

在这里插入图片描述

准备CUpdateServlet(修改数据)

package world;import java.io.IOException;import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;import world.country;
import world.countrydao;public class CUpdateServlet extends HttpServlet {protected void service(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {request.setCharacterEncoding("UTF-8");country country = new country();country.setId(Integer.parseInt(request.getParameter("id")));country.setName(request.getParameter("name"));country.setsurfacearea(Float.parseFloat(request.getParameter("surfacearea")));country.setpopulation(Integer.parseInt(request.getParameter("population")));new countrydao().update(country);response.sendRedirect("/j2ee/listc");}
}

在这里插入图片描述

配置web.xml

    <servlet><servlet-name>CEditServlet</servlet-name><servlet-class>world.CEditServlet</servlet-class></servlet><servlet-mapping><servlet-name>CEditServlet</servlet-name><url-pattern>/edit</url-pattern></servlet-mapping><servlet><servlet-name>CUpdateServlet</servlet-name><servlet-class>world.CUpdateServlet</servlet-class></servlet><servlet-mapping><servlet-name>CUpdateServlet</servlet-name><url-pattern>/update</url-pattern></servlet-mapping>

三,总结

以上便是整个CURD案例的全部源代码了,每一步都有详细的介绍,虽然参考了其他的学习案例,但是本测试是根据mysql的案例类专门设计的。测试的过程中,基本把所有的报错都踩了一边,略有感慨,小写一篇文章以分享和记录。

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

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

RabbitMQ消息模型之Routing-Topic

Routing Topic Topic类型的Exchange与Direct相比&#xff0c;都是可以根据RoutingKey把消息路由到不同的队列。只不过Topic类型Exchange可以让队列在绑定Routing key的时候使用通配符&#xff01;这种模型Routingkey一般都是由一个或多个单词组成&#xff0c;多个单词之间以”…

ESP32-Web-Server编程- WebSocket 编程

ESP32-Web-Server编程- WebSocket 编程 概述 在前述 ESP32-Web-Server 实战编程-通过网页控制设备的 GPIO 中&#xff0c;我们创建了一个基于 HTTP 协议的 ESP32 Web 服务器&#xff0c;每当浏览器向 Web 服务器发送请求&#xff0c;我们将 HTML/CSS 文件提供给浏览器。 使用…

智能手表上的音频(四):语音通话

上篇讲了智能手表上音频文件播放。本篇开始讲语音通话。同音频播放一样有两种case&#xff1a;内置codec和BT。先看这两种case下audio data path&#xff0c;分别如下图&#xff1a; 内置codec下的语音通话audio data path 蓝牙下的语音通话audio data path 从上面两张图可以看…

纯js实现录屏并保存视频到本地的尝试

前言&#xff1a;先了解下&#xff1a;navigator.mediaDevices&#xff0c;mediaDevices 是 Navigator 只读属性&#xff0c;返回一个 MediaDevices 对象&#xff0c;该对象可提供对相机和麦克风等媒体输入设备的连接访问&#xff0c;也包括屏幕共享。 const media navigator…

【刷题】DFS

DFS 递归&#xff1a; 1.判断是否失败终止 2.判断是否成功终止&#xff0c;如果成功的&#xff0c;记录一个成果 3.遍历各种选择&#xff0c;在这部分可以进行剪枝 4.在每种情况下进行DFS&#xff0c;并进行回退。 199. 二叉树的右视图 给定一个二叉树的 根节点 root&#x…

深度学习之十二(图像翻译AI算法--UNIT(Unified Neural Translation))

概念 UNIT(Unified Neural Translation)是一种用于图像翻译的 AI 模型。它是一种基于生成对抗网络(GAN)的框架,用于将图像从一个域转换到另一个域。在图像翻译中,这意味着将一个风格或内容的图像转换为另一个风格或内容的图像,而不改变图像的内容或语义。 UNIT 的核心…

IDEA2022 Git 回滚及回滚内容恢复

IDEA2022 Git 回滚 ①选择要回滚的地方&#xff0c;右键选择 ②选择要回滚的模式 ③开始回滚 ④soft模式回滚的内容会保留在暂存区 ⑤输入git push -f &#xff0c;然后重新提交&#xff0c;即可同步远程 注意观察IDEA右下角分支的标记&#xff0c;蓝色代表远程内容未同步到本…

数据结构 / day06 作业

1.下面的代码打印在屏幕上的值是多少? /下面的代码打印在屏幕上的值是多少?#include "stdio.h"int compute_data(int arr[], unsigned int len) {long long int result 0;if(result len)return arr[0];resultcompute_data(arr,--len);printf("len%d, res…

elementui中table进行表单验证

<el-form :model"ruleForm" ref"ruleForm" class"demo-ruleForm"><el-table :data"ruleForm.tableDataShou" border style"width: 100%;"><el-table-column type"index" label"序号" wi…

【23种设计模式·全精解析 | 自定义Spring框架篇】Spring核心源码分析+自定义Spring的IOC功能,依赖注入功能

文章目录 ⭐⭐⭐Spring核心源码分析自定义Spring框架⭐⭐⭐一、Spring使用回顾二、Spring核心功能结构1、Spring核心功能2、bean概述 三、Spring IOC相关接口分析1、BeanFactory解析2、BeanDefinition解析3、BeanDefinitionReader解析4、BeanDefinitionRegistry解析5、创建容器…

伪集群配置

编辑core-site 配置core-site 配置hdfs-site 将以下的文件配置进去 启动一下hadoop产生tmp文件 产生这个叫namenode的文件并格式化 回到~目录 再配置以下信息 配置以下信息 重启文件 再重新格式化配置namenode 再启动一下&#xff0c;然后jps看看&#xff0c;出现这样就…

java后端自学总结

自学总结 MessageSource国际化接口总结 MessageSource国际化接口 今天第一次使用MessageSource接口,比较意外遇到了一些坑 messageSource是spring中的转换消息接口&#xff0c;提供了国际化信息的能力。MessageSource用于解析 消息&#xff0c;并支持消息的参数化和国际化。 S…

运维知识点-openResty

openResty 企业级实战——畅购商城SpringCloud-网站首页高可用解决方案-openRestynginxlua——实现广告缓存测试企业级实战——畅购商城SpringCloud-网站首页高可用解决方案-openRestynginxlua——OpenResty 企业级实战——畅购商城SpringCloud-网站首页高可用解决方案-openRes…

优化器原理——权重衰减(weight_decay)

优化器原理——权重衰减&#xff08;weight_decay&#xff09; weight_decay的作用 原理解析 实验观察 在深度学习中&#xff0c;优化器的 weight_decay 参数扮演着至关重要的角色。它主要用于实现正则化&#xff0c;以防止模型过拟合。过拟合是指模型在训练数据上表现优异&…

从意义中恢复,而不是从数据包中恢复

从书报&#xff0c;录放机&#xff0c;电视机到智能手机&#xff0c;vr 眼镜&#xff0c;所有学习的&#xff0c;娱乐的工具或玩具&#xff0c;几乎都以光声诉诸视听&#xff0c;一块屏幕和一个喇叭。 视觉和听觉对任何动物都是收发信息的核心&#xff0c;诉诸视觉和听觉的光和…

机器学习笔记 - 3D数据的常见表示方式

一、简述 从单一角度而自动合成3D数据是人类视觉和大脑的基本功能,这对计算机视觉算法来说是比较难的。但随着LiDAR、RGB-D 相机(RealSense、Kinect)和3D扫描仪等3D传感器的普及和价格的降低,3D 采集技术的最新进展取得了巨大飞跃。与广泛使用的 2D 数据不同,3D 数据具有丰…

[node] Node.js 中Stream流

[node] Node.js 中Stream流 什么是 Stream流操作从流中读取数据写入流管道流链式流 什么是 Stream Stream 是一个抽象接口&#xff0c;Node 中有很多对象实现了这个接口。例如&#xff0c;对http 服务器发起请求的request 对象就是一个 Stream&#xff0c;还有stdout&#xff…

(C++)复写零--双指针法

个人主页&#xff1a;Lei宝啊 愿所有美好如期而遇 力扣&#xff08;LeetCode&#xff09;官网 - 全球极客挚爱的技术成长平台备战技术面试&#xff1f;力扣提供海量技术面试资源&#xff0c;帮助你高效提升编程技能&#xff0c;轻松拿下世界 IT 名企 Dream Offer。https://le…

ESP32-Web-Server 实战编程- 使用 AJAX 自动更新网页内容

ESP32-Web-Server 实战编程- 使用 AJAX 自动更新网页内容 概述 什么是 AJAX &#xff1f; AJAX Asynchronous JavaScript and XML&#xff08;异步的 JavaScript 和 XML&#xff09;。 AJAX 是一种用于创建快速动态网页的技术。 传统的网页&#xff08;不使用 AJAX&#…

Linux 进程(一)

1 操作系统 概念&#xff1a;任何计算机系统都包含一个基本的程序集合&#xff0c;称为操作系统(OS)。笼统的理解&#xff0c;操作系统包括 内核&#xff08;进程管理&#xff0c;内存管理&#xff0c;文件管理&#xff0c;驱动管理&#xff09; 其他程序&#xff08;例…