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

JDBC+HTML+AJAX实现登陆和单表的CRUD

JDBC+HTML+AJAX实现登陆和单表的CRUD

导入maven依赖

<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">  <modelVersion>4.0.0</modelVersion>  <groupId>com.nie</groupId>  <artifactId>Test</artifactId>  <version>1.0-SNAPSHOT</version>  <packaging>war</packaging><properties> <maven.compiler.source>17</maven.compiler.source>  <maven.compiler.target>17</maven.compiler.target>  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties><dependencies><dependency><groupId>jakarta.servlet</groupId><artifactId>jakarta.servlet-api</artifactId><version>6.0.0</version><scope>provided</scope></dependency><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>8.0.33</version></dependency><dependency><groupId>com.google.code.gson</groupId><artifactId>gson</artifactId><version>2.10.1</version></dependency></dependencies>
</project>

登陆页面


<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>用户登录</title><script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script><style>.container {width: 300px;margin: 100px auto;padding: 20px;border: 1px solid #ccc;border-radius: 5px;}.form-group {margin-bottom: 15px;}.form-group label {display: block;margin-bottom: 5px;}.form-group input {width: 100%;padding: 8px;border: 1px solid #ddd;border-radius: 4px;}.btn-login {background-color: #007bff;color: white;padding: 10px 20px;border: none;border-radius: 4px;cursor: pointer;}.error-message {color: red;margin-top: 10px;display: none;}</style>
</head>
<body>
<div class="container"><form action="login" method="post" id="loginForm"><div class="form-group"><label for="username">用户名:</label><input type="text" id="username" name="username" required></div><div class="form-group"><label for="password">密码:</label><input type="password" id="password" name="password" required></div><button type="submit" class="btn-login">登录</button></form><div id="errorMessage" class="error-message"></div>
</div>
</body>
<script>$(document).ready(function () {$("#loginForm").submit(function () {var username = $("#username").val();var password = $("#password").val();$.ajax({type: "POST",url: "/login",dataType: "text",data: { username: username, password: password },success: function (response) {if (response === "success") {window.location.href = "Test1.html";}}})})})
</script>
</html> 

学生信息页面

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"><meta http-equiv="X-UA-Compatible" content="ie=edge"><title>学生信息表</title><script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
</head>
<body>
<div></div>
<div><input type="text" id="names" placeholder="输入学生姓名"><button id="chaxun">查询姓名</button><button id="all">查询所有</button><table width="50%" border="1"><tr align="center"><td>学号</td><td>姓名</td><td>性别</td><td>邮箱</td></tr><tbody id="test"></tbody></table>
</div>
<div>学号:<input type="text" name="" id="id">姓名:<input type="text" name="" id="name">性别:<input type="text" name="" id="sex">邮箱:<input type="text" name="" id="email"><br><button id="insert">新增数据</button>
</div>
<script>function deleteStudent(id) {$.ajax({url: '/delete',type: "POST",dataType: "text",data: { id: id },success: function (data) {if (data === "success") {alert("数据删除成功!");$("#all").click()} else {alert("删除数据失败!");}},error: function () {alert("删除数据失败!");}})}function updateStudent(id) {let id1=document.getElementById("id").valuelet name=document.getElementById("name").valuelet sex=document.getElementById("sex").valuelet email=document.getElementById("email").value$.ajax({url: '/update',type: "POST",dataType: "text",data: { id: id ,id1:id1,name:name,sex:sex,email:email},success: function (data) {if (data === "success") {alert("数据修改成功!");$("#all").click()} else {alert("数据修改失败!");}},error: function () {alert("数据修改失败!");}})}$(document).ready(function () {$("#all").click(function () {$.ajax({url: './api/students',type: "GET",dataType: "json",success: function (data) {console.log("Received data:", data);var html = "";for (var i = 0; i < data.length; i++) {var ls = data[i];html +="<tr>" +"<td>" + ls.id + "</td>" +"<td>" + ls.name + "</td>" +"<td>" + ls.sex + "</td>" +"<td>" + ls.email + "</td>" +"<td>" +"<button onclick='deleteStudent(" + ls.id + ")'>删除</button>" +"<button onclick='updateStudent(" + ls.id + ")'>修改</button>" +"</td>" +"</tr>";}$("#test").html(html);},error: function (xhr, status, error) {console.error("Error details:", {status: xhr.status,statusText: xhr.statusText,responseText: xhr.responseText});alert("获取数据失败,请检查控制台错误信息");}});});$("#chaxun").click(function () {var names = document.getElementById("names").value;$.ajax({url: './api/studentsByName',type: "GET",dataType: "json",data: { name: names },success: function (data) {console.log("Received data:", data);var html = "";for (var i = 0; i < data.length; i++) {var ls = data[i];html +="<tr>" +"<td>" + ls.id + "</td>" +"<td>" + ls.name + "</td>" +"<td>" + ls.sex + "</td>" +"<td>" + ls.email + "</td>" +"</tr>";}$("#test").html(html);},error: function () {alert("获取数据失败");}});});$("#insert").click(function (){var id = document.getElementById("id").value; // 获取输入框的值var name = document.getElementById("name").value; // 获取输入框的值var sex = document.getElementById("sex").value; // 获取输入框的值var email = document.getElementById("email").value; // 获取输入框的值$.ajax({type: "POST",url: '/insert',dataType: "text",data: { id: id, name: name, sex: sex, email: email },success: function (response) {if (response === "success") {alert("数据新增成功!");$("#all").click();} else {alert("新增数据失败!");}},error: function () {alert("新增数据失败!");}});});});
</script>
</body>
</html>

JDBC连接数据库

package com.nie.utils;import java.sql.*;public class GetConnection {private static String url="jdbc:mysql://127.0.0.1:3306/student";private static String user="root";private static String password="123456";static {try {Class.forName("com.mysql.cj.jdbc.Driver");} catch (ClassNotFoundException e) {throw new RuntimeException(e);}}public static Connection getConnection() throws SQLException {return DriverManager.getConnection(url,user,password);}public void close(Connection conn, PreparedStatement stmt, ResultSet rs) throws SQLException {conn.close();stmt.close();rs.close();}}

登陆实体类

package com.nie.pojo;public class loginStudent {private String username;private String password;public String getUsername() {return username;}public void setUsername(String username) {this.username = username;}public String getPassword() {return password;}public void setPassword(String password) {this.password = password;}
}

学生实体类

package com.nie.pojo;public class student {private String id;private String name;private String sex;private String email;public String getId() {return id;}public void setId(String id) {this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}public String getSex() {return sex;}public void setSex(String age) {this.sex = age;}public String getEmail() {return email;}public void setEmail(String email) {this.email = email;}@Overridepublic String toString() {return "student{" +"id=" + id +", name='" + name + '\'' +", age='" + sex + '\'' +", email='" + email + '\'' +'}';}
}

dao层

package com.nie.dao;import com.nie.pojo.loginStudent;
import com.nie.pojo.student;
import com.nie.utils.GetConnection;import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;public class StudentDao {static Connection conn = null;static PreparedStatement pstmt = null;static ResultSet rs = null;public static List<student> selectAll() throws SQLException {conn= GetConnection.getConnection();List<student> list = new ArrayList<student>();pstmt=conn.prepareStatement("select * from student");rs=pstmt.executeQuery();while (rs.next()) {student student = new student();student.setId(rs.getString("id"));student.setName(rs.getString("name"));student.setSex(rs.getString("sex"));student.setEmail(rs.getString("email"));list.add(student);}return list;}public static List<student> selectByName(String name) throws SQLException {conn=GetConnection.getConnection();pstmt=conn.prepareStatement("select  * from student where name = ?");pstmt.setString(1, name);rs=pstmt.executeQuery();List<student> list=new ArrayList<>();while (rs.next()) {student student = new student();student.setId(rs.getString("id"));student.setName(rs.getString("name"));student.setSex(rs.getString("sex"));student.setEmail(rs.getString("email"));list.add(student);}return list;}public static int insertStudent(student student) throws SQLException {conn=GetConnection.getConnection();pstmt=conn.prepareStatement("insert into student (id,name,sex,email) values(?,?,?,?)");pstmt.setString(1,student.getId());pstmt.setString(2,student.getName());pstmt.setString(3,student.getSex());pstmt.setString(4,student.getEmail());int i = pstmt.executeUpdate();return i;}public static List<loginStudent>  selectslogin(loginStudent loginStudent) throws SQLException {conn=GetConnection.getConnection();pstmt=conn.prepareStatement("select * from login where username = ? and password = ?");pstmt.setString(1,loginStudent.getUsername());pstmt.setString(2,loginStudent.getPassword());rs=pstmt.executeQuery();List<loginStudent> list=new ArrayList<>();if(rs.next()) {loginStudent login = new loginStudent();login.setUsername(rs.getString("username"));login.setPassword(rs.getString("password"));list.add(login);}return list;}public static int DeleteStudent(String id) throws SQLException {conn=GetConnection.getConnection();pstmt=conn.prepareStatement("delete from student where id = ?");pstmt.setString(1,id);int i = pstmt.executeUpdate();return i;}public static int UpdateStudent(String id,String id1,String name,String sex,String email) throws SQLException {conn=GetConnection.getConnection();pstmt=conn.prepareStatement("update student set id=?,name=?,sex=?,email=? where id=?");pstmt.setString(1,id1);pstmt.setString(2,name);pstmt.setString(3,sex);pstmt.setString(4,email);pstmt.setString(5,id);int i = pstmt.executeUpdate();return i;}
}

业务层

删除

package com.nie.server;import com.nie.dao.StudentDao;
import com.sun.net.httpserver.HttpsServer;
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.SQLException;@WebServlet("/delete")
public class DeleteStudent extends HttpServlet {@Overrideprotected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {doPost(req,resp);}@Overrideprotected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {String id = req.getParameter("id");try {int i = StudentDao.DeleteStudent(id);if(i>0){resp.getWriter().write("success");}else {resp.getWriter().write("fail");}} catch (SQLException e) {throw new RuntimeException(e);}}
}

添加

package com.nie.server;import com.nie.dao.StudentDao;
import com.nie.pojo.student;
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.SQLException;@WebServlet("/insert")
public class InsertStudent extends HttpServlet {@Overrideprotected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {doPost(req, resp);}@Overrideprotected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {String id = req.getParameter("id");String name = req.getParameter("name");String sex = req.getParameter("sex");String email = req.getParameter("email");student student = new student();student.setId(id);student.setName(name);student.setSex(sex);student.setEmail(email);try {int i = StudentDao.insertStudent(student);if (i > 0) {resp.getWriter().write("success");} else {resp.getWriter().write("fail");}} catch (SQLException e) {e.printStackTrace();resp.getWriter().write("fail");}}
}

登陆

package com.nie.server;import com.nie.dao.StudentDao;
import com.nie.pojo.loginStudent;
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.SQLException;
import java.util.List;@WebServlet("/login")
public class loginServlet extends HttpServlet {@Overrideprotected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {String username = req.getParameter("username");String password = req.getParameter("password");loginStudent loginStudent = new loginStudent();loginStudent.setUsername(username);loginStudent.setPassword(password);try {List<loginStudent> selectslogin = StudentDao.selectslogin(loginStudent);if(selectslogin.size()>0) {resp.getWriter().write("success");}else {resp.getWriter().write("fail");}} catch (SQLException e) {throw new RuntimeException(e);}}@Overrideprotected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {doPost(req, resp);}
}

查询

package com.nie.server;import com.google.gson.Gson;
import com.nie.dao.StudentDao;
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.SQLException;@WebServlet("/api/students")
public class ServletStudent extends HttpServlet {@Overrideprotected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {String name = req.getParameter("name");Gson gson = new Gson();String jsonResponse = null;try {if (name != null){jsonResponse = gson.toJson(StudentDao.selectByName(name));}else {jsonResponse = gson.toJson(StudentDao.selectAll());}} catch (SQLException e) {throw new RuntimeException(e);}// 设置响应头,确保返回JSONresp.setContentType("application/json");resp.setCharacterEncoding("UTF-8");// 添加CORS头,允许跨域访问(如果需要的话)resp.setHeader("Access-Control-Allow-Origin", "*");resp.getWriter().write(jsonResponse);}@Overrideprotected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {doGet(req,resp);}
}

根据姓名查询

package com.nie.server;import com.google.gson.Gson;
import com.nie.dao.StudentDao;
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.SQLException;@WebServlet("/api/studentsByName")
public class ServletStudentByName extends HttpServlet {@Overrideprotected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {String name = req.getParameter("name");Gson gson = new Gson();String jsonResponse = null;try {jsonResponse = gson.toJson(StudentDao.selectByName(name));} catch (SQLException e) {throw new RuntimeException(e);}// 设置响应头,确保返回JSONresp.setContentType("application/json");resp.setCharacterEncoding("UTF-8");// 添加CORS头,允许跨域访问(如果需要的话)resp.setHeader("Access-Control-Allow-Origin", "*");resp.getWriter().write(jsonResponse);}@Overrideprotected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {doGet(req,resp);}
}

修改

package com.nie.server;import com.nie.dao.StudentDao;
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.SQLException;@WebServlet("/update")
public class UpdateStudent extends HttpServlet {@Overrideprotected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {doPost(req,resp);}@Overrideprotected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {String id = req.getParameter("id");String id1 = req.getParameter("id1");String name = req.getParameter("name");String sex = req.getParameter("sex");String email = req.getParameter("email");try {int i = StudentDao.UpdateStudent(id, id1, name, sex, email);if (i>0) {resp.getWriter().write("success");} else {resp.getWriter().write("fail");}} catch (SQLException e) {throw new RuntimeException(e);}}
}

最终效果:
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

相关文章:

JDBC+HTML+AJAX实现登陆和单表的CRUD

JDBCHTMLAJAX实现登陆和单表的CRUD 导入maven依赖 <?xml version"1.0" encoding"UTF-8"?><project xmlns"http://maven.apache.org/POM/4.0.0" xmlns:xsi"http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocatio…...

Leetcode 3568. Minimum Moves to Clean the Classroom

Leetcode 3568. Minimum Moves to Clean the Classroom 1. 解题思路2. 代码实现 题目链接&#xff1a;3568. Minimum Moves to Clean the Classroom 1. 解题思路 这一题我的核心思路就是广度优先遍历遍历剪枝。 显然&#xff0c;我们可以给出一个广度优先遍历来给出所有可能…...

Kafka多线程Consumer

Apache Kafka作为一款分布式流处理平台&#xff0c;以其高吞吐量和可扩展性在大数据处理领域占据了重要地位。在实际应用中&#xff0c;为了提升数据处理的效率和灵活性&#xff0c;我们常常需要采用多线程的方式来消费Kafka中的数据。本文将通过一个案例分析&#xff0c;详细探…...

从零开始的git学习

基本概念&#xff1a;修改记录 1、每个修改记录都有对应的id 2、当发现修改有问题时&#xff0c;可以进行回滚操作。 3、回滚的本质是一次新的更新以复原修改。但是如果不是针对最新记录进行回滚&#xff0c;会出现冲突。 这里需要举例说明 基本概念&#xff1a;分支 1、分支…...

【C++】位图详解(一文彻底搞懂位图的使用方法与底层原理)

&#x1f308; 个人主页&#xff1a;谁在夜里看海. &#x1f525; 个人专栏&#xff1a;《C系列》《Linux系列》 ⛰️ 天高地阔&#xff0c;欲往观之。 目录 1.位图的概念 2.位图的使用方法 定义与创建 设置和清除 位访问和检查 转换为其他格式 3.位图的使用场景 1.快速…...

Spring Boot 整合 JdbcTemplate,JdbcTemplate 与 MyBatis 的区别

DAY29.1 Java核心基础 Spring Boot 整合 JdbcTemplate JdbcTemplate是一个轻量级JDBC封装的组件 JdbcTemplate 是 Spring 自带的JDBC的封装&#xff0c;和Mybatis类似&#xff0c;需要自己封装sql语句 JdbcTemplate 帮助我们来连接数据库&#xff0c;SQL的执行&#xff0c;…...

sass基础语法

Sass&#xff08;Syntactically Awesome Style Sheets&#xff09;是一种 CSS 预处理器&#xff0c;提供了比原生 CSS 更强大、更灵活的语法功能。它有两种语法格式&#xff1a; Sass&#xff08;缩进语法&#xff0c;.sass 文件&#xff09;SCSS&#xff08;CSS-like 语法&am…...

【EF Core】 EF Core 批量操作的进化之路——从传统变更跟踪到无跟踪更新

文章目录 前言一、批量操作&#xff08;Rang&#xff09;1.1 AddRange()1.2 UpdateRange()1.3 AttachRange()1.4 RemoveRange() 二、Range操作的底层优化2.1 EF Core 7 前举步维艰2.2 EF Core 7后焕然一新 三、无跟踪的批量更新与删除3.1 ExecuteUpdate3.2 ExecuteDelete3.3 状…...

[Go] Option选项设计模式 — — 编程方式基础入门

[Go] Option选项设计模式 — — 编程方式基础入门 全部代码地址&#xff0c;欢迎⭐️ Github&#xff1a;https://github.com/ziyifast/ziyifast-code_instruction/tree/main/go-demo/go-option 1 介绍 在 Go 开发中&#xff0c;我们经常遇到需要处理多参数配置的场景。传统方…...

Vue 项目命名规范指南

&#x1f4da; Vue 项目命名规范指南&#xff08;适用于 Vue 3 Pinia Vue Router&#xff09; 目的&#xff1a;统一命名风格&#xff0c;提升可读性、可维护性和团队协作效率。 一、通用原则 类型命名风格示例变量camelCaseuserName, isLoading常量UPPER_SNAKE_CASEMAX_RET…...

【笔记】开源通用人工智能代理 Suna 部署全流程准备清单(Windows 系统)

#工作记录 一、基础工具与环境 开发工具 Git 或 GitHub Desktop&#xff08;代码管理&#xff09;Docker Desktop&#xff08;需启用 WSL2&#xff0c;容器化部署&#xff09;Python 3.11&#xff08;推荐版本&#xff0c;需添加到系统环境变量&#xff09;Node.js LTS&#xf…...

海康工业相机SDK二次开发(VS+QT+海康SDK+C++)

前言 工业相机在现代制造和工业自动化中扮演了至关重要的角色&#xff0c;尤其是在高精度、高速度检测中。海康威视工业相机以其性能稳定、图像质量高、兼容性强而受到广泛青睐。特别是搞机器视觉的小伙伴们跟海康打交道肯定不在少数&#xff0c;笔者在平常项目中跟海康相关人…...

前端面试准备-5

1.Node.js中的process.nectTick()有什么作用 将一个回调函数插入到当前执行栈的尾部&#xff0c;在下一次事件轮询之前调用这个回调函数 2.什么是Node.js中的事件发射器&#xff0c;作用是什么&#xff0c;如何使用 提供一种机制&#xff0c;可以创建、触发和监听自定义事件…...

Spring Boot 启动流程深度解析:从源码到实践

Spring Boot 启动流程深度解析&#xff1a;从源码到实践 Spring Boot 作为 Java 开发的主流框架&#xff0c;其 “约定大于配置” 的理念极大提升了开发效率。本文将从源码层面深入解析 Spring Boot 的启动流程&#xff0c;并通过代码示例展示其工作机制。 一、Spring Boot 启…...

深度学习|pytorch基本运算-乘除法和幂运算

【1】引言 前序学习进程中&#xff0c;已经对pytorch张量数据的生成和广播做了详细探究&#xff0c;文章链接为&#xff1a; 深度学习|pytorch基本运算-CSDN博客 深度学习|pytorch基本运算-广播失效-CSDN博客 上述探索的内容还止步于张量的加减法&#xff0c;在此基础上&am…...

嵌入式通用集成电路卡市场潜力报告:物联网浪潮下的机遇与挑战剖析

一、嵌入式通用集成电路卡概述​ 嵌入式通用集成电路卡&#xff08;Embedded Universal Integrated Circuit Card&#xff0c;简称 eUICC&#xff09;&#xff0c;是一种将传统 SIM 卡功能直接嵌入到设备主板上的芯片解决方案 。与传统可插拔式 SIM 卡不同&#xff0c;eUICC 采…...

4.2.4 Spark SQL 数据写入模式

在本节实战中&#xff0c;我们详细探讨了Spark SQL中数据写入的四种模式&#xff1a;ErrorIfExists、Append、Overwrite和Ignore。通过具体案例&#xff0c;我们演示了如何使用mode()方法结合SaveMode枚举类来控制数据写入行为。我们首先读取了一个JSON文件生成DataFrame&#…...

论文笔记: Urban Region Embedding via Multi-View Contrastive Prediction

AAAI 2024 1 INTRO 之前基于多视图的region embedding工作大多遵循相同的模式 单独的单视图表示多视图融合 但这种方法存在明显的局限性&#xff1a;忽略了不同视图之间的信息一致性 一个区域的多个视图所携带的信息是高度相关的&#xff0c;因此它们的表示应该是一致的如果能…...

Android 缓存应用冻结器(Cached Apps Freezer)

一、核心功能与原理 1. 功能概述 目标&#xff1a;通过冻结后台缓存应用的进程&#xff0c;减少其对 CPU、内存等系统资源的消耗&#xff0c;优化设备性能与续航。适用场景&#xff1a;针对行为不当的后台应用&#xff08;如后台偷偷运行代码、占用 CPU&#xff09;&#xff…...

初学者如何微调大模型?从0到1详解

本文将手把手带你从0到1&#xff0c;详细解析初学者如何微调大模型&#xff0c;让你也能驾驭这些强大的AI工具。 1. 什么是大模型微调&#xff1f; 想象一下&#xff0c;预训练大模型就像一位博览群书但缺乏专业知识的通才。它掌握了海量的通用知识&#xff0c;但可能无法完美…...

西瓜书第十一章——降维与度量学习

文章目录 降维与度量学习k近邻学习原理头歌实战-numpy实现KNNsklearn实现KNN 降维——多维缩放&#xff08;Multidimensional Scaling, MDS&#xff0c;MDS&#xff09;提出背景与原理重述1.**提出背景**2.**数学建模与原理推导**3.**关键推导步骤** Principal Component Analy…...

Portainer安装指南:多节点监控的docker管理面板-家庭云计算专家

背景 Portainer 是一个轻量级且功能强大的容器管理面板&#xff0c;专为 Docker 和 Kubernetes 环境设计。它通过直观的 Web 界面简化了容器的部署、管理和监控&#xff0c;即使是非技术用户也能轻松上手。Portainer 支持多节点管理&#xff0c;允许用户从一个中央控制台管理多…...

NanoGPT的BenchMarking.py

1.Benchmarking是一种评估和比较性能的过程。在深度学习领域&#xff0c;它通常涉及对模型的训练速度、推理速度、内存占用等指标进行测量&#xff0c;以便评估不同模型、不同硬件配置或者不同软件版本之间的性能差异。 例如&#xff0c;当你尝试比较两个不同架构的模型&#x…...

测试用例及黑盒测试方法

一、测试用例 1.1 基本要素 测试用例&#xff08;Test Case&#xff09;是为了实施测试而向被测试的系统提供的一组集合&#xff0c;这组集合包含&#xff1a;测试环境、操作步骤、测试数据、预期结果等4个主要要素。 1.1.1 测试环境 定义&#xff1a;测试执行所需的软硬件…...

CentOS 7 环境下部署 LAMP

在 CentOS 7 环境下部署 LAMP&#xff08;Linux Apache MySQL 5.7 PHP 7.4&#xff09; 环境的详细步骤如下&#xff1a; 1. 系统准备 1.1 更新系统 sudo yum update -y 1.2 安装依赖 sudo yum install -y gcc pcre pcre-devel zlib zlib-devel openssl openssl-devel e…...

vscode实用配置

前端开发安装插件&#xff1a; 1.可以更好看的显示文件图标 2.用户快速打开文件 使用步骤&#xff1a;在html文件下右键点击 open with live server 即可 刷力扣&#xff1a; 安装这个插件 还需要安装node.js即可...

React 项目中封装 Excel 导入导出组件:技术分享与实践

文章目录 前言一、为什么需要封装 Excel 组件&#xff1f;二、技术选型三、核心实现1. 安装依赖2. 封装Excel导出3. 封装导入组件 &#xff08;UploadExcel&#xff09; 总结 前言 在 React 项目中&#xff0c;处理 Excel 文件的导入和导出是常见的业务需求。无论是导出报表数…...

【PhysUnits】15.1 引入P1后的加一特质(add1.rs)

一、源码 代码实现了类型系统中的"加一"操作&#xff08;Add1 trait&#xff09;&#xff0c;用于在编译期进行数字的增量计算。 //! 加一操作特质实现 / Increment operation trait implementation //! //! 说明&#xff1a; //! 1. Z0、P1,、N1 1&#xff0…...

【2025CCF中国开源大会】RISC-V 开源生态的挑战与机遇分论坛重磅来袭!共探开源芯片未来

点击蓝字 关注我们 CCF Opensource Development Committee 开源浪潮正从软件席卷硬件领域&#xff0c;RISC-V作为全球瞩目的开源芯片架构&#xff0c;正在重塑计算生态的版图&#xff01;相较于成熟的x86与ARM&#xff0c;RISC-V生态虽处爆发初期&#xff0c;却蕴藏着无限可能。…...

python完成批量复制Excel文件并根据另一个Excel文件中的名称重命名

import openpyxl import shutil import os # 原始文件路径 original_file "C:/Users/Administrator/Desktop/事业联考面试名单/郑州.xlsx" # 读取包含名称的Excel文件 # 修改为您的文件名 wb openpyxl.load_workbook( "C:/Users/Administrator/Desktop/事…...