diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 65246c3..4c68a24 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -10,8 +10,7 @@
-
-
+
@@ -362,7 +361,7 @@
-
+
@@ -468,7 +467,15 @@
1745135922838
-
+
+
+ 1745222555582
+
+
+
+ 1745222555582
+
+
diff --git a/src/com/controller/deptadmin/DeptAlterStuPunchServlet.java b/src/com/controller/deptadmin/DeptAlterStuPunchServlet.java
index b968fbd..c1dd2c8 100644
--- a/src/com/controller/deptadmin/DeptAlterStuPunchServlet.java
+++ b/src/com/controller/deptadmin/DeptAlterStuPunchServlet.java
@@ -1,45 +1,49 @@
-package com.controller.deptadmin;
+package com.controller.deptadmin;//这一行定义了当前类所在的包,com.controller.deptadmin 表示该类是 deptadmin 包下的控制器类。
-import com.dao.DeptAdminDao;
+import com.dao.DeptAdminDao;//导入 DeptAdminDao 类,这个类通常包含与数据库交互的代码。它用于执行数据库操作,比如执行 update 或 select 操作。
-import javax.servlet.ServletException;
-import javax.servlet.annotation.WebServlet;
+import javax.servlet.ServletException;//ServletException 用于处理 Servlet 的异常。
+import javax.servlet.annotation.WebServlet;//WebServlet 是用于定义 Servlet 的注解。
+//HttpServlet, HttpServletRequest, HttpServletResponse 是 HTTP 协议相关的 Servlet 类,处理请求和响应。
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
+import java.io.IOException;//IOException 用于处理输入输出相关的异常。
-@WebServlet("/DeptAlterStuPunchServlet")
-public class DeptAlterStuPunchServlet extends HttpServlet {
+@WebServlet("/DeptAlterStuPunchServlet")//这是一个注解,用来声明这个 Servlet 的 URL 映射路径。用户访问 /DeptAlterStuPunchServlet 路径时会触发该 Servlet。
+public class DeptAlterStuPunchServlet extends HttpServlet {//这是定义一个 DeptAlterStuPunchServlet 类,它继承自 HttpServlet,说明这是一个处理 HTTP 请求的 Servlet 类。
+ //这是重写的 doGet 方法,处理 HTTP GET 请求。每当用户通过 GET 请求访问该 Servlet 时,doGet 方法会被调用。
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
req.setCharacterEncoding("utf-8");
resp.setCharacterEncoding("utf-8");
- resp.setContentType("text/html;charset=utf-8");
-
- //获取表单请求的参数
- String sno = req.getParameter("sno");
- String sispunch = req.getParameter("sispunch");
- String spunchdate = req.getParameter("spunchdate");
- String spunchtime = req.getParameter("spunchtime");
- String sishot = req.getParameter("sishot");
- String siscough = req.getParameter("siscough");
- String sisseem = req.getParameter("sisseem");
- String sisdiagnose = req.getParameter("sisdiagnose");
- String sstatus = req.getParameter("sstatus");
-
+ resp.setContentType("text/html;charset=utf-8");//设置请求和响应的字符编码为 UTF-8,确保请求和响应的文本内容能够正确处理中文字符。
+
+ //从 HTTP 请求中获取用户提交的表单参数
+ String sno = req.getParameter("sno");//学生学号
+ String sispunch = req.getParameter("sispunch");//是否打卡
+ String spunchdate = req.getParameter("spunchdate");//打卡日期
+ String spunchtime = req.getParameter("spunchtime");//打卡时间
+ String sishot = req.getParameter("sishot");//是否发热
+ String siscough = req.getParameter("siscough");//是否咳嗽
+ String sisseem = req.getParameter("sisseem");//是否有乏力
+ String sisdiagnose = req.getParameter("sisdiagnose");//诊断结果
+ String sstatus = req.getParameter("sstatus");//打卡状态
+
+ //构造了一个 SQL 更新语句,用于修改 stupunchin 表中的数据。更新的字段包括打卡状态、时间、症状信息等,查询条件是 sno(学生学号)和 spunchdate(打卡日期)。
String sql = "update stupunchin set sispunch = ?, spunchtime = ?, sishot = ?, siscough = ?, sisseem = ?, sisdiagnose = ?, sstatus = ? where sno = ? and spunchdate = ?";
- Object[] objects = {sispunch, spunchtime, sishot, siscough, sisseem, sisdiagnose, sstatus, sno, spunchdate};
+ Object[] objects = {sispunch, spunchtime, sishot, siscough, sisseem, sisdiagnose, sstatus, sno, spunchdate};//创建一个对象数组 objects,该数组包含了 SQL 更新语句中使用的参数。数组中的值会被传递给数据库操作。
- int num = DeptAdminDao.executeUpdate(sql, objects);
+ int num = DeptAdminDao.executeUpdate(sql, objects);//调用 DeptAdminDao 类中的 executeUpdate 方法执行 SQL 更新操作。该方法会返回受影响的行数(更新成功的记录数),并将其赋值给 num 变量。
- System.out.println(num);
+ System.out.println(num);//打印更新操作影响的记录行数,通常用于调试和查看更新操作的效果。
- req.getRequestDispatcher("/DeptQueryStuPunchByPageServlet?currentPage=1&rows=7&sname=&sclass=&spunchdate=").forward(req, resp);
+ req.getRequestDispatcher("/DeptQueryStuPunchByPageServlet?currentPage=1&rows=7&sname=&sclass=&spunchdate=").forward(req, resp);//调用 RequestDispatcher 的 forward 方法,将请求转发到另一个 Servlet,通常是用于显示更新后的学生打卡信息。这会将用户重定向到 DeptQueryStuPunchByPageServlet,并附带了一些查询参数。
}
+ //这是重写的 doPost 方法。由于 doPost 方法的实现只是调用了 doGet,这意味着该 Servlet 支持同时处理 GET 和 POST 请求。实际上,POST 请求会被当作 GET 请求处理。
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
doGet(req, resp);