Update README.md

pull/2/head
hql 5 months ago
parent 8720469af5
commit 091928c5c4

@ -10,7 +10,8 @@
</component>
<component name="ChangeListManager">
<list default="true" id="0ffa26fe-3275-4667-90ad-c688ca600b30" name="Default Changelist" comment="Update README.md">
<change beforePath="$PROJECT_DIR$/src/com/controller/alluse/LoginServlet.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/com/controller/alluse/LoginServlet.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/com/controller/deptadmin/DeptAddStuPunchServlet.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/com/controller/deptadmin/DeptAddStuPunchServlet.java" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -68,20 +69,20 @@
<component name="ProjectViewState">
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"RunOnceActivity.git.unshallow": "true",
"git-widget-placeholder": "feature/hql",
"kotlin-language-version-configured": "true",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
"node.js.selected.package.tslint": "(autodetect)",
"nodejs_package_manager_path": "npm",
"settings.editor.selected.configurable": "terminal",
"vue.rearranger.settings.migration": "true"
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;RunOnceActivity.git.unshallow&quot;: &quot;true&quot;,
&quot;git-widget-placeholder&quot;: &quot;feature/hql&quot;,
&quot;kotlin-language-version-configured&quot;: &quot;true&quot;,
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
&quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
&quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
&quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
&quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;terminal&quot;,
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
}
}]]></component>
}</component>
<component name="RecentsManager">
<key name="CopyClassDialog.RECENTS_KEY">
<recent name="com.filter" />
@ -358,7 +359,8 @@
<workItem from="1589092133957" duration="947000" />
<workItem from="1745045574258" duration="638000" />
<workItem from="1745046236628" duration="3804000" />
<workItem from="1745050261322" duration="392000" />
<workItem from="1745050261322" duration="1665000" />
<workItem from="1745132180317" duration="1443000" />
</task>
<task id="LOCAL-00001" summary="Update README.md">
<option name="closed" value="true" />
@ -376,7 +378,15 @@
<option name="project" value="LOCAL" />
<updated>1745050571734</updated>
</task>
<option name="localTasksCounter" value="3" />
<task id="LOCAL-00003" summary="Update README.md">
<option name="closed" value="true" />
<created>1745050664664</created>
<option name="number" value="00003" />
<option name="presentableId" value="LOCAL-00003" />
<option name="project" value="LOCAL" />
<updated>1745050664664</updated>
</task>
<option name="localTasksCounter" value="4" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">

@ -7,54 +7,59 @@ import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.IOException; //导入IO异常和日期类
import java.util.Date;
@WebServlet("/DeptAddStuPunchServlet")
public class DeptAddStuPunchServlet extends HttpServlet {
public class DeptAddStuPunchServlet extends HttpServlet { //定义一个继承自HttpServlet的Servlet类。
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { //重写doGet方法处理HTTP GET请求。
//统一请求和响应的字符编码为UTF-8防止中文乱码并设置响应内容类型为HTML。
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");
String sno = req.getParameter("sno"); //从 HTTP 请求中获取参数名为 "sno" 的值,并将其赋值给 sno 变量
String sispunch = req.getParameter("sispunch");//从 HTTP 请求中获取参数名为 "sispunch" 的值,并将其赋值给 sispunch 变量
String spunchdate = req.getParameter("spunchdate");//从 HTTP 请求中获取参数名为 "spunchdate" 的值,并将其赋值给 spunchdate 变量
String spunchtime = req.getParameter("spunchtime");//从 HTTP 请求中获取参数名为 "spunchtime" 的值,并将其赋值给 spunchtime 变量
String sishot = req.getParameter("sishot");//从 HTTP 请求中获取参数名为 "sishot" 的值,并将其赋值给 sishot 变量
String siscough = req.getParameter("siscough");//从 HTTP 请求中获取参数名为 "siscough" 的值,并将其赋值给 siscough 变量
String sisseem = req.getParameter("sisseem");//从 HTTP 请求中获取参数名为 "sisseem" 的值,并将其赋值给 sisseem 变量
String sisdiagnose = req.getParameter("sisdiagnose");//从 HTTP 请求中获取参数名为 "sisdiagnose" 的值,并将其赋值给 sisdiagnose 变量
String sstatus = req.getParameter("sstatus");//从 HTTP 请求中获取参数名为 "sstatus" 的值,并将其赋值给 sstatus 变量
String sql = null;
//声明SQL语句变量并输出调试信息
System.out.println("shgshgh");
//查询是否存在此人
sql = "select count(*) as num from stupunchin where sno = ? and spunchdate = ?";
Object[] objects = {sno, spunchdate};
int count = DeptAdminDao.findTotalCount(sql, objects);
sql = "select count(*) as num from stupunchin where sno = ? and spunchdate = ?";//检查stupunchin表中是否存在相同学号和日期的记录
Object[] objects = {sno, spunchdate}; //使用Object数组传递参数防止SQL注入。
int count = DeptAdminDao.findTotalCount(sql, objects);//调用DAO方法findTotalCount返回匹配记录数。
if (count == 0){//无则操作
if (count == 0){//条件判断如果不存在重复记录count为0执行插入操作。
sql = "insert into stupunchin values(?, ?, ?, ?, ?, ?, ?, ?, ?)";
Object[] objects1 = {sno, sispunch, spunchdate, spunchtime, sishot, siscough, sisseem, sisdiagnose, sstatus};
//SQL插入语句向stupunchin表插入包含9个字段的新记录。
//参数绑定:将表单参数按顺序填入占位符。
int num = DeptAdminDao.executeUpdate(sql, objects1);
int num = DeptAdminDao.executeUpdate(sql, objects1);//执行更新调用DAO方法executeUpdate执行插入返回受影响的行数。
System.out.println(num);
req.getRequestDispatcher("/DeptQueryStuPunchByPageServlet?currentPage=1&rows=7&sname=&sclass=&spunchdate=").forward(req, resp);
}else {
req.getRequestDispatcher("/view/alluse/existdataofadd.jsp").forward(req, resp);
}
req.getRequestDispatcher("/view/alluse/existdataofadd.jsp").forward(req, resp);//转发请求插入成功后转发到分页查询Servlet显示第一页数据参数currentPage=1每页7行
}//处理重复数据如果记录已存在转发到提示页面existdataofadd.jsp。
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
doGet(req, resp);
doGet(req, resp);//处理POST请求重写doPost方法直接调用doGet统一处理GET和POST请求。
}
}

Loading…
Cancel
Save