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

构建 Java Web 应用程序:实现简单的增删查改(Mysql)

简介

本教程将指导您如何使用Java Servlet和JSP技术构建一个简单的Web应用程序。该应用程序将包括用户注册、登录、注销(删除用户信息)、修改密码以及根据性别查询用户信息等功能。我们将使用MySQL数据库来存储用户数据。

环境准备

  1. Java Development Kit (JDK): 安装JDK 8或更高版本。
  2. IDE: 推荐使用IntelliJ IDEA或Eclipse。
  3. Servlet容器: 如Apache Tomcat 9或更高版本。
  4. MySQL数据库: 安装并运行MySQL服务。

步骤 1: 设置数据库

  1. 打开MySQL命令行工具。
  2. 创建数据库 student
  3. 执行 t.jsp 中的SQL语句创建 info 表。
<%@ page import="java.sql.*" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head><title>创建表并插入数据</title>
</head>
<body>
<%Connection conn = null;Statement stmt = null;try {// 加载 MySQL JDBC 驱动程序Class.forName("com.mysql.cj.jdbc.Driver");// 创建数据库连接conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/student?useSSL=false&serverTimezone=UTC", "root", "123456");// 创建 Statement 对象stmt = conn.createStatement();// 创建表的 SQL 语句String createTableSql = "CREATE TABLE IF NOT EXISTS info (" +"id INT AUTO_INCREMENT PRIMARY KEY, " +"name VARCHAR(255) NOT NULL, " +"email VARCHAR(255) NOT NULL, " +"age INT NOT NULL, " +"gender VARCHAR(10) NOT NULL, " +"password VARCHAR(255) NOT NULL, " +"hobbies VARCHAR(255), " +"introduction TEXT" +")";// 执行创建表的 SQL 语句stmt.executeUpdate(createTableSql);out.println("表创建成功!");// 插入数据的 SQL 语句String insertSql = "INSERT INTO info (name, email, age, gender, password, hobbies, introduction) " +"VALUES ('John Doe', 'john.doe@example.com', 22, 'Male', 'password123', 'Reading, Hiking', 'A passionate learner and explorer.')";// 执行插入数据的 SQL 语句int affectedRows = stmt.executeUpdate(insertSql);if (affectedRows > 0) {out.println("数据插入成功!");} else {out.println("数据插入失败!");}} catch (Exception e) {out.println("数据库错误: " + e.getMessage());} finally {// 关闭 Statement 和 Connection 对象try {if (stmt != null) stmt.close();} catch (SQLException se2) {// 忽略关闭错误}try {if (conn != null) conn.close();} catch (SQLException se) {// 忽略关闭错误}}
%>
</body>
</html>

步骤 2: 创建项目和配置环境

  1. 在IDE中创建一个新的Java Web项目。
  2. 配置项目的构建路径,包括JDK和Servlet API库。

步骤 3: 实现数据库连接

  1. DBConnection.java 中配置数据库连接参数。
package import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;public class DBConnection {private static final String DRIVER = "com.mysql.cj.jdbc.Driver";private static final String URL = "jdbc:mysql://localhost:3306/student?useSSL=false&serverTimezone=UTC";private static final String USERNAME = "root";private static final String PASSWORD = "123456";/*** 获取数据库连接* @return 数据库连接对象*/public static Connection getConnection() {Connection conn = null;try {// 加载 MySQL JDBC 驱动程序Class.forName(DRIVER);// 创建数据库连接conn = DriverManager.getConnection(URL, USERNAME, PASSWORD);System.out.println("MySQL JDBC driver is loaded and connection is established.");} catch (ClassNotFoundException e) {System.out.println("MySQL JDBC driver is not found.");e.printStackTrace();} catch (SQLException e) {System.out.println("Failed to establish a database connection.");e.printStackTrace();}return conn;}
}
  1. 实现 getConnection 方法,用于获取数据库连接。

步骤 4: 实现业务逻辑

  1. 用户注册: 在 RegServlet.java 中实现用户注册逻辑。
package ;import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;@WebServlet("/RegServlet")
public class RegServlet extends HttpServlet {private static final long serialVersionUID = 1L;protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {String name = request.getParameter("name");String email = request.getParameter("email");String password = request.getParameter("password");String gender = request.getParameter("gender");String ageStr = request.getParameter("age");String[] hobbiesArray = request.getParameterValues("hobby"); // 兴趣爱好可能有多个String introduction = request.getParameter("introduction");// 将爱好数组转换为由逗号分隔的字符串String hobbies = (hobbiesArray != null) ? String.join(", ", hobbiesArray) : "";Student student = new Student();student.setName(name);student.setEmail(email);student.setGender(gender);student.setPassword(password);student.setAge(Integer.parseInt(ageStr)); // 确保 age 参数可以转换为整数student.setHobbies(hobbies);student.setIntroduction(introduction);StudentDAO studentDAO = new StudentDAO(); // 使用 StudentDAO 来处理业务逻辑Result result = studentDAO.insertStudent(student); // 调用 insertStudent 方法if (result.isSuccess()) { response.sendRedirect("login.jsp");} else {response.sendRedirect("error.jsp");}}protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {// 可以选择显示注册表单或者重定向到注册页面response.sendRedirect("index.jsp");}
}
  1. 用户登录: 在 LoginServlet.java 中实现用户登录逻辑。

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;
import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;import cn.edu.hbcit.dml.DBConnection;@WebServlet("/LoginServlet")
public class LoginServlet extends HttpServlet {private static final long serialVersionUID = 1L;protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {String email = request.getParameter("email");String password = request.getParameter("password");Connection conn = null; // 将 conn 声明移动到 try 块外部try {conn = DBConnection.getConnection();PreparedStatement pstmt = conn.prepareStatement("SELECT * FROM info WHERE email=? AND password=?");pstmt.setString(1, email);pstmt.setString(2, password);ResultSet rs = pstmt.executeQuery();if (rs.next()) {HttpSession session = request.getSession();session.setAttribute("user", rs.getString("name"));session.setAttribute("userEmail", email); // 存储用户邮箱到会话session.setAttribute("userPassword", password); // 存储用户密码到会话response.sendRedirect("home.jsp");} else {response.sendRedirect("login.jsp?error=invalidCredentials");}} catch (SQLException e) {e.printStackTrace();response.sendRedirect("login.jsp?error=databaseError");} finally {try {if (conn != null) conn.close();} catch (SQLException ex) {ex.printStackTrace();}}}
}
  1. 注销: 在 DelServlet.java 中实现注销逻辑。
package import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;import Student;public class DelStudent {private static final Logger logger = Logger.getLogger(DelStudent.class.getName());/*** 根据邮箱和密码删除学生信息的方法。* @param student 包含要删除的学生信息的对象* @return 操作结果,包含是否成功和消息*/public Result deleteStudent(Student student) {String sql = "DELETE FROM info WHERE email = ? AND password = ?"; // 删除语句try (Connection conn = DBConnection.getConnection(); // 直接使用静态方法获取连接PreparedStatement pstmt = conn.prepareStatement(sql)) {// 设置 PreparedStatement 参数为邮箱和密码pstmt.setString(1, student.getEmail());pstmt.setString(2, student.getPassword());// 执行删除操作int affectedRows = pstmt.executeUpdate();if (affectedRows > 0) {logger.log(Level.INFO, "数据删除成功,影响行数:{0}", affectedRows);System.out.println("删除成功,影响行数:" + affectedRows); // 输出到控制台return new Result(true, "删除成功");} else {logger.log(Level.WARNING, "删除失败,没有行受到影响");System.out.println("删除失败,没有行受到影响"); // 输出到控制台return new Result(false, "删除失败");}} catch (SQLException e) {logger.log(Level.SEVERE, "数据库错误: " + e.getMessage(), e);System.out.println("数据库错误: " + e.getMessage()); // 输出到控制台return new Result(false, "数据库错误: " + e.getMessage());}}
}
  1. 修改密码: 实现 ChangePasswordServlet.java
package import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;import DBConnection;@WebServlet("/ChangePasswordServlet")
public class ChangePasswordServlet extends HttpServlet {private static final long serialVersionUID = 1L;protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {String email = request.getParameter("email");String oldPassword = request.getParameter("oldPassword");String newPassword = request.getParameter("newPassword");String confirmPassword = request.getParameter("confirmPassword");// 检查新密码是否输入一致if (!newPassword.equals(confirmPassword)) {request.setAttribute("error", "新密码不匹配");request.getRequestDispatcher("changePassword.jsp").forward(request, response);return;}// 获取数据库连接Connection conn = DBConnection.getConnection();// 验证旧密码try {PreparedStatement pstmt = conn.prepareStatement("SELECT password FROM info WHERE email = ?");pstmt.setString(1, email);ResultSet rs = pstmt.executeQuery();if (rs.next() && rs.getString("password").equals(oldPassword)) {// 旧密码正确,更新新密码PreparedStatement updatePstmt = conn.prepareStatement("UPDATE info SET password = ? WHERE email = ?");updatePstmt.setString(1, newPassword);updatePstmt.setString(2, email);int affectedRows = updatePstmt.executeUpdate();if (affectedRows > 0) {// 密码更新成功,重定向到登录页面response.sendRedirect("login.jsp?message=密码修改成功");} else {// 密码更新失败request.setAttribute("error", "密码更新失败");request.getRequestDispatcher("changePassword.jsp").forward(request, response);}} else {// 旧密码错误或用户不存在request.setAttribute("error", "旧密码错误或用户不存在");request.getRequestDispatcher("changePassword.jsp").forward(request, response);}} catch (SQLException e) {throw new ServletException("数据库错误: " + e.getMessage());} finally {try {if (conn != null) conn.close();} catch (SQLException ex) {ex.printStackTrace();}}}protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {// 重定向到修改密码表单页面response.sendRedirect("login.jsp");}
}
  1. 查询用户信息: 实现 QueryServlet.java
package ;import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;import Student;@WebServlet("/QueryServlet")
public class QueryServlet extends HttpServlet {private static final long serialVersionUID = 1L;protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {response.setContentType("text/html;charset=UTF-8");PrintWriter out = response.getWriter();String sex = request.getParameter("sex");System.out.print("查询性别: " + sex);ArrayList<Student> students = new ArrayList<>();try (Connection conn = DBConnection.getConnection();PreparedStatement pstmt = conn.prepareStatement("SELECT name, email, age, gender, hobbies, introduction FROM info WHERE gender = ?")) {pstmt.setString(1, sex);ResultSet rs = pstmt.executeQuery();while (rs.next()) {Student student = new Student();student.setName(rs.getString("name"));student.setEmail(rs.getString("email"));student.setAge(rs.getInt("age"));student.setGender(rs.getString("gender"));student.setHobbies(rs.getString("hobbies"));student.setIntroduction(rs.getString("introduction"));students.add(student);}} catch (SQLException e) {e.printStackTrace();out.println("数据库错误: " + e.getMessage());}request.setAttribute("students", students);request.getRequestDispatcher("QueryResult.jsp").forward(request, response);}protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {doGet(request, response);}
}

步骤 5: 创建用户界面

  1. 注册页面: 创建 index.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head><title>用户注册页面</title><style>body {font-family: Arial, sans-serif;display: flex;justify-content: center;align-items: center;height: 100vh;margin: 0;background-color: #fff;}.background-image {position: fixed;bottom: 0;left: 0;width: 500px;height: 320px;background-image: url('bg.png');background-size: cover;z-index: -1;}.container {width: 600px;padding: 20px;background-color: rgba(255, 255, 255, 0.9); /* 半透明背景 */border-radius: 8px;box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);backdrop-filter: blur(10px); /* 毛玻璃特效 */display: flex;flex-direction: column;}.form-group {margin-bottom: 15px;display: flex;align-items: center;}.form-group label {flex: 1;margin-right: 10px;}.form-group input[type="text"],.form-group input[type="email"],.form-group input[type="password"],.form-group input[type="number"],.form-group textarea {flex: 2;padding: 8px;border: 1px solid #ddd;border-radius: 4px;}.form-group input[type="radio"],.form-group input[type="checkbox"] {margin-right: 5px;}.form-group textarea {resize: none;}.hobbies {display: flex;justify-content: space-between;}.register-btn {width: 100%;padding: 10px;background-color: blue;color: white;border: none;border-radius: 4px;cursor: pointer;}.register-btn:hover {background-color: darkblue;}</style>
</head>
<body><div class="background-image"></div><div class="container"><h2>用户注册</h2><form action="RegServlet" method="post"><div class="form-group"><label for="name">昵称:</label><input type="text" id="name" name="name" required></div><div class="form-group"><label for="email">注册邮箱:</label><input type="email" id="email" name="email" required></div><div class="form-group"><label for="password">密码:</label><input type="password" id="password" name="password" required></div><div class="form-group"><label>性别:</label><input type="radio" id="male" name="gender" value="male"><label for="male"></label><input type="radio" id="female" name="gender" value="female"><label for="female"></label></div><div class="form-group"><label for="age">年龄:</label><input type="number" id="age" name="age" required></div><div class="form-group"><label>兴趣爱好:</label><div class="hobbies"><input type="checkbox" id="hobby1" name="hobby" value="hobby1"><label for="hobby1">爱好1</label><input type="checkbox" id="hobby2" name="hobby" value="hobby2"><label for="hobby2">爱好2</label><input type="checkbox" id="hobby3" name="hobby" value="hobby3"><label for="hobby3">爱好3</label></div><div class="hobbies"><input type="checkbox" id="hobby4" name="hobby" value="hobby4"><label for="hobby4">爱好4</label><input type="checkbox" id="hobby5" name="hobby" value="hobby5"><label for="hobby5">爱好5</label><input type="checkbox" id="hobby6" name="hobby" value="hobby6"><label for="hobby6">爱好6</label></div></div><div class="form-group"><label for="introduction">自我介绍:</label><textarea id="introduction" name="introduction" maxlength="100" required></textarea></div><button type="submit" class="register-btn">立即注册</button></form></div>
</body>
</html>
  1. 登录页面: 创建 login.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head><title>登录页面</title><style>body {font-family: Arial, sans-serif;background-color: #f7f7f7;padding: 20px;}.login-container {max-width: 300px;margin: 0 auto;background: #fff;padding: 20px;border-radius: 5px;box-shadow: 0 2px 4px rgba(0,0,0,0.1);}label {display: block;margin-bottom: 5px;}input[type="email"],input[type="password"] {width: 100%;padding: 10px;margin-bottom: 10px;border: 1px solid #ddd;border-radius: 4px;}button {width: 100%;padding: 10px;background-color: #5cb85c;color: white;border: none;border-radius: 4px;cursor: pointer;}button:hover {background-color: #4cae4c;}</style>
</head>
<body><div class="login-container"><h2>登录</h2><form action="LoginServlet" method="post"><div><label for="email">邮箱:</label><input type="email" id="email" name="email" required></div><div><label for="password">密码:</label><input type="password" id="password" name="password" required></div><button type="submit">登录</button></form></div>
</body>
</html>
  1. 修改密码页面: 创建 changePassword.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head><title>修改密码</title><style>body {font-family: 'Arial', sans-serif;background-color: #f7f7f7;padding: 20px;}.form-container {max-width: 300px;margin: 0 auto;background: #fff;padding: 20px;border-radius: 5px;box-shadow: 0 2px 4px rgba(0,0,0,0.1);}label {display: block;margin-bottom: 5px;}input[type="text"],input[type="password"] {width: 100%;padding: 10px;margin-bottom: 10px;border: 1px solid #ddd;border-radius: 4px;}button {width: 100%;padding: 10px;background-color: #5cb85c;color: white;border: none;border-radius: 4px;cursor: pointer;}button:hover {background-color: #4cae4c;}.error-message {color: red;margin-bottom: 10px;}</style>
</head>
<body><div class="form-container"><h2>修改密码</h2><% if(request.getAttribute("error") != null) { %><div class="error-message"><%= request.getAttribute("error") %></div><% } %><form action="ChangePasswordServlet" method="post"><label for="email">邮箱:</label><input type="text" id="email" name="email" required><br><label for="oldPassword">旧密码:</label><input type="password" id="oldPassword" name="oldPassword" required><br><label for="newPassword">新密码:</label><input type="password" id="newPassword" name="newPassword" required><br><label for="confirmPassword">确认新密码:</label><input type="password" id="confirmPassword" name="confirmPassword" required><br><button type="submit">提交</button></form></div>
</body>
</html>
  1. 查询页面: 创建 Query.jsp
    8
  2. 查询结果页面: 创建 QueryResult.jsp

步骤 6: 部署和测试

  1. 将项目部署到Tomcat服务器。
  2. 启动Tomcat服务器。
  3. 在浏览器中测试所有功能。

结论

通过本教程,您将学会如何使用Java Servlet和JSP构建一个完整的Web应用程序。这个项目涵盖了用户注册、登录、注销、修改密码和查询等基本功能,是学习Java Web开发的好起点。

附录

  • 数据库配置: 数据库连接字符串和JDBC驱动。
  • Servlet映射: web.xml 中的Servlet配置。
  • 错误处理: 如何在应用程序中处理和显示错误信息。

相关文章:

构建 Java Web 应用程序:实现简单的增删查改(Mysql)

简介 本教程将指导您如何使用Java Servlet和JSP技术构建一个简单的Web应用程序。该应用程序将包括用户注册、登录、注销&#xff08;删除用户信息&#xff09;、修改密码以及根据性别查询用户信息等功能。我们将使用MySQL数据库来存储用户数据。 环境准备 Java Development …...

3d行政区划-中国地图

前言 技术调研&#xff1a;做底代码平台的3d行政区组件 写的demo 效果图&#xff1a; 实现的功能项 地标、打点、飞线、three.js 3d 中国地图的一些基础配置补充 geo中国地图文件获取 其他项:包 "dependencies": {"d3": "^7.9.0","d3-…...

适合存储时序数据的数据库和存储系统

时序数据的存储通常要求高效地处理大量按时间排序的数据&#xff0c;同时支持快速查询、实时分析和高并发写入。以下是一些适合存储时序数据的数据库和存储系统&#xff1a; 1. InfluxDB 概述&#xff1a;InfluxDB 是一个开源的时序数据库&#xff0c;专门为处理时序数据而设…...

dolphinscheduler集群服务一键安装启动实现流程剖析

1.dolphinscheduler的安装部署 dolphinscheduler服务的安装部署都是非常简单的&#xff0c;因为就服务本身而言依赖的服务并不多。 mysql / postgresql。由于需要进行元数据及业务数据的持久化存储所以需要依赖于数据库服务&#xff0c;数据库服务支持mysql、postgresql等&am…...

深入了解Linux —— 学会使用vim编辑器

前言 学习了Linux中的基本指令也理解了权限这一概念&#xff0c;但是我们怎么在Linux下写代码呢&#xff1f; 本篇就来深入学习Linux下的vim编辑器&#xff1b;学会在Linux下写代码。 软件包管理器 1. 软件包&#xff1f; 在Linux下安装软件&#xff0c;通常是下载程序的源码…...

C05S01-Web基础和HTTP协议

一、Web基础 1. Web相关概念 1.1 URL URL&#xff08;Uniform Resource Locator&#xff0c;统一资源定位符&#xff09;&#xff0c;是一种用于在互联网上标识和定位资源的标准化地址&#xff0c;提供了一种访问互联网上特定资源的方法。URL的基本格式如下所示&#xff1a;…...

MIT工具课第六课任务 Git基础练习题

如果您之前从来没有用过 Git&#xff0c;推荐您阅读 Pro Git 的前几章&#xff0c;或者完成像 Learn Git Branching 这样的教程。重点关注 Git 命令和数据模型相关内容&#xff1b; 相关内容整理链接&#xff1a;Linux Git新手入门 git常用命令 Git全面指南&#xff1a;基础概念…...

计算机网络安全

从广义来说&#xff0c;凡是涉及到网络上信息的机密性、报文完整性、端点鉴别等技术和理论都是网络安全的研究领域。 机密性指仅有发送方和接收方能理解传输报文的内容&#xff0c;而其他未授权用户不能解密&#xff08;理解&#xff09;该报文报文完整性指报文在传输过程中不…...

Delphi 实现键盘模拟、锁定键盘,锁定鼠标等操作

Delphi 模拟按键的方法 SendMessageA 说明: 调用一个窗口的窗口函数&#xff0c;将一条消息发给那个窗口。除非消息处理完毕&#xff0c;否则该函数不会返回SendMessage所包含4个参数: 1. hwnd 32位的窗口句柄窗口可以是任何类型的屏幕对象&#xff0c;因为Win32能够维护大多数…...

RTK数据的采集方法

采集RTK&#xff08;实时动态定位&#xff09;数据通常涉及使用高精度的GNSS&#xff08;全球导航卫星系统&#xff09;接收器&#xff0c;并通过基站和流动站的配合来实现。本文给出RTK数据采集的基本步骤 文章目录 准备设备设置基站设置流动站数据采集数据存储与处理应用数据…...

Next.js 入门学习

一、引言 在现代 Web 开发领域&#xff0c;Next.js 已成为构建高性能、可扩展且用户体验卓越的 React 应用程序的重要框架。它基于 React 并提供了一系列强大的特性和工具&#xff0c;能够帮助开发者更高效地构建服务器端渲染&#xff08;SSR&#xff09;、静态站点生成&#…...

2024年认证杯SPSSPRO杯数学建模B题(第一阶段)神经外科手术的定位与导航解题全过程文档及程序

2024年认证杯SPSSPRO杯数学建模 B题 神经外科手术的定位与导航 原题再现&#xff1a; 人的大脑结构非常复杂&#xff0c;内部交织密布着神经和血管&#xff0c;所以在大脑内做手术具有非常高的精细和复杂程度。例如神经外科的肿瘤切除手术或血肿清除手术&#xff0c;通常需要…...

安卓底层相机流的传输方式

这是安卓 相机流的定义 typedef enum {CAM_STREAMING_MODE_CONTINUOUS, /* continous streaming */CAM_STREAMING_MODE_BURST, /* burst streaming */CAM_STREAMING_MODE_BATCH, /* stream frames in batches */CAM_STREAMING_MODE_MAX} cam_streaming_mode_t; 在ca…...

【单链表】(更新中...)

一、 题单 206.反转链表203.移除链表元素 876.链表的中间结点BM8 链表中倒数最后k个结点21.合并两个有序链表 二、题目简介及思路 206.反转链表 给你单链表的头节点 head &#xff0c;请你反转链表&#xff0c;并返回反转后的链表。 思路简单&#xff0c;但是除了要两个指针进…...

开源堡垒机JumpServer配置教程:使用步骤与配置

开源堡垒机JumpServer配置教程&#xff1a;使用步骤与配置 上一篇文章星哥讲了如何安装JumpServer堡垒机&#xff0c;本篇文章来讲如何配置和使用JumpServer。 安装成功后&#xff0c;通过浏览器访问登录 JumpServer 地址: http://<JumpServer服务器IP地址>:<服务运…...

上门服务小程序开发,打造便捷生活新体验

随着互联网的快速发展&#xff0c;各种上门服务成为了市场的发展趋势&#xff0c;不管是各种外卖、家政、美甲、维修、按摩等等&#xff0c;都可以提供上门服务&#xff0c;人们足不出户就可以满足各种需求&#xff0c;商家也能够获得新的拓展业务渠道&#xff0c;提高整体收益…...

iOS中的类型推断及其在Swift编程语言中的作用和优势

iOS中的类型推断及其在Swift编程语言中的作用和优势 一、iOS中的类型推断 类型推断&#xff08;Type Inference&#xff09;是编程语言编译器或解释器自动推断变量或表达式的类型的能力。在支持类型推断的语言中&#xff0c;开发者在声明变量时无需显式指定其类型&#xff0c…...

工业检测基础-缺陷形态和相机光源选型

缺陷形态与相机选择依据 微小点状缺陷&#xff08;如微小气泡、杂质颗粒&#xff09; 相机选择依据&#xff1a; 分辨率&#xff1a;需要高分辨率相机&#xff0c;无论是面阵还是线阵相机&#xff0c;以确保能够清晰地分辨这些微小的点。对于面阵相机&#xff0c;像元尺寸要小&…...

Python100道练习题

Python100道练习题 BIlibili 1、两数之和 num1 20 num2 22result num1 num2print(result)2、一百以内的偶数 list1 []for i in range(1,100):if i % 2 0:list1.append(i) print(list1)3、一百以内的奇数 # 方法一 list1 [] for i in range(1,100):if i % 2 ! 0:lis…...

2024年华中杯数学建模A题太阳能路灯光伏板的朝向设计问题解题全过程文档及程序

2024年华中杯数学建模 A题 太阳能路灯光伏板的朝向设计问题 原题再现 太阳能路灯由太阳能电池板组件部分&#xff08;包括支架&#xff09;、LED灯头、控制箱&#xff08;包含控制器、蓄电池&#xff09;、市电辅助器和灯杆几部分构成。太阳能电池板通过支架固定在灯杆上端。…...

通过Wrangler CLI在worker中创建数据库和表

官方使用文档&#xff1a;Getting started Cloudflare D1 docs 创建数据库 在命令行中执行完成之后&#xff0c;会在本地和远程创建数据库&#xff1a; npx wranglerlatest d1 create prod-d1-tutorial 在cf中就可以看到数据库&#xff1a; 现在&#xff0c;您的Cloudfla…...

vue3 字体颜色设置的多种方式

在Vue 3中设置字体颜色可以通过多种方式实现&#xff0c;这取决于你是想在组件内部直接设置&#xff0c;还是在CSS/SCSS/LESS等样式文件中定义。以下是几种常见的方法&#xff1a; 1. 内联样式 你可以直接在模板中使用style绑定来设置字体颜色。 <template><div :s…...

OpenPrompt 和直接对提示词的嵌入向量进行训练有什么区别

OpenPrompt 和直接对提示词的嵌入向量进行训练有什么区别 直接训练提示词嵌入向量的核心区别 您提到的代码: prompt_embedding = initial_embedding.clone().requires_grad_(True) optimizer = torch.optim.Adam([prompt_embedding...

图表类系列各种样式PPT模版分享

图标图表系列PPT模版&#xff0c;柱状图PPT模版&#xff0c;线状图PPT模版&#xff0c;折线图PPT模版&#xff0c;饼状图PPT模版&#xff0c;雷达图PPT模版&#xff0c;树状图PPT模版 图表类系列各种样式PPT模版分享&#xff1a;图表系列PPT模板https://pan.quark.cn/s/20d40aa…...

NXP S32K146 T-Box 携手 SD NAND(贴片式TF卡):驱动汽车智能革新的黄金组合

在汽车智能化的汹涌浪潮中&#xff0c;车辆不再仅仅是传统的交通工具&#xff0c;而是逐步演变为高度智能的移动终端。这一转变的核心支撑&#xff0c;来自于车内关键技术的深度融合与协同创新。车载远程信息处理盒&#xff08;T-Box&#xff09;方案&#xff1a;NXP S32K146 与…...

iOS性能调优实战:借助克魔(KeyMob)与常用工具深度洞察App瓶颈

在日常iOS开发过程中&#xff0c;性能问题往往是最令人头疼的一类Bug。尤其是在App上线前的压测阶段或是处理用户反馈的高发期&#xff0c;开发者往往需要面对卡顿、崩溃、能耗异常、日志混乱等一系列问题。这些问题表面上看似偶发&#xff0c;但背后往往隐藏着系统资源调度不当…...

QT3D学习笔记——圆台、圆锥

类名作用Qt3DWindow3D渲染窗口容器QEntity场景中的实体&#xff08;对象或容器&#xff09;QCamera控制观察视角QPointLight点光源QConeMesh圆锥几何网格QTransform控制实体的位置/旋转/缩放QPhongMaterialPhong光照材质&#xff08;定义颜色、反光等&#xff09;QFirstPersonC…...

A2A JS SDK 完整教程:快速入门指南

目录 什么是 A2A JS SDK?A2A JS 安装与设置A2A JS 核心概念创建你的第一个 A2A JS 代理A2A JS 服务端开发A2A JS 客户端使用A2A JS 高级特性A2A JS 最佳实践A2A JS 故障排除 什么是 A2A JS SDK? A2A JS SDK 是一个专为 JavaScript/TypeScript 开发者设计的强大库&#xff…...

Caliper 配置文件解析:fisco-bcos.json

config.yaml 文件 config.yaml 是 Caliper 的主配置文件,通常包含以下内容: test:name: fisco-bcos-test # 测试名称description: Performance test of FISCO-BCOS # 测试描述workers:type: local # 工作进程类型number: 5 # 工作进程数量monitor:type: - docker- pro…...

OD 算法题 B卷【正整数到Excel编号之间的转换】

文章目录 正整数到Excel编号之间的转换 正整数到Excel编号之间的转换 excel的列编号是这样的&#xff1a;a b c … z aa ab ac… az ba bb bc…yz za zb zc …zz aaa aab aac…; 分别代表以下的编号1 2 3 … 26 27 28 29… 52 53 54 55… 676 677 678 679 … 702 703 704 705;…...