个人作业
每日打卡APP
项目背景:
石家庄铁道大学软件工程系从本学期开始要求21级学生每日打卡总结,特委托石家庄铁道大学给力21软件有限公司进行开发。
每日总结打卡:内容包括:日期、每日关键字、每日总结、坚持天数(自动计数,显示上次天数)、连续最长天数。
package com.mf;
import java.sql.Connection;
import java.sql.PreparedStatement;
public class Interface {
public boolean add( model){
String riqi =model.riqi();
String keyword =model.keyword();
String zongjie =model.zongjie();
String inday =model.inday();
String maxday =model.maxday();
Util db=new Util();
try {
String sql="INSERT INTO day(riqi,keyword,zongjie,inday,maxday) VALUES (?,?,?,?,?)";
Connection conn=db.getCon();
PreparedStatement ps=conn.prepareStatement(sql);
ps.setString(1, riqi);
ps.setString(2, keyword);
ps.setString(3, zongjie);
ps.setString(4, inday);
ps.setString(5, maxday);
ps.executeUpdate();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return true;
}
}
package com;
public class model {
private String riqi;
private String keyword;
private String zongjie;
private String inday;
private static String maxday;
public String getRiqi() {
return riqi;
}
public void setRiqi(String riqi) {
this.riqi = riqi;
}
public String getKeyword() {
return keyword;
}
public void setKeyword(String keyword) {
this.keyword = keyword;
}
public String getZongjie() {
return zongjie;
}
public void setZongjie(String zongjie) {
this.zongjie = zongjie;
}
public String getInday() {
return inday;
}
public void setInday(String inday) {
this.inday = inday;
}
public String getMaxday() {
return maxday;
}
public void setMaxday(String maxday) {
this.maxday = maxday;
}
}
package com;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class Util {
private String url="jdbc:mysql://localhost:3306/db-jsp";
private String user="root";
private String password="123456";
private String driver="com.mysql.jdbc.Driver";
public Connection getCon() throws Exception{
Class.forName(driver);
Connection con=DriverManager.getConnection(url, user, password);
return con;
}
public static void getClose(Connection con) throws SQLException{
if(con!=null){
con.close();
}
}
}
package com;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class web extends HttpServlet {
Util db=new Util();
private static final long serialVersionUID = 1L;
public PublishServlet() {
super();
}
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=UTF-8");
String riqi=request.getParameter("riqi");
String keyword=request.getParameter("keyword");
String zongjie=request.getParameter("zongjie");
String inday=request.getParameter("inday");
String maxday=request.getParameter("maxday");
Interface=new Interface();
Interface.setriqi(riqi);
literature.setEnglishName(EnglishName);
literature.setType(Type);
literature.setAuthor(Author);
literature.setSource(Source);
literature.setChineseAbstract(ChineseAbstract);
literature.setEnglishAbstract(EnglishAbstract);
literature.setChineseKeyword(ChineseKeyword);
literature.setEnglishKeyword(EnglishKeyword);
literature.setReforName(ReforName);
literature.setIncentive(Incentive);
literature.setContent(Content);
LiteratureInterface literatureInter=new LiteratureInterface();
literatureInter.addLiterature(literature);
request.getRequestDispatcher("main.jsp").forward(request, response);
}
public void init() throws ServletException {
// Put your code here
}
}
<%--
Created by IntelliJ IDEA.
User: 也远
Date: 2023/2/20
Time: 17:06
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>每日总结打卡</title>
</head>
<body>
<form action="PublishServlet" method="post">
<table>
<tr>
<td>日期:</td>
<td><input type="text" name="riqi" value="${param.riqi}"></td>
</tr>
<tr>
<td>每日关键字:</td>
<td><input type="text" name="keyword" value="${param.keyword}"></td>
</tr>
<tr>
<td>每日总结:</td>
<td><input type="text" name="zongjie" value="${param.zongjie}"></td>
</tr>
<tr>
<td>坚持天数:</td>
<td><input type="text" name="inday" value="${param.inday}"></td>
</tr>
<tr>
<td>连续最长天数:</td>
<td><input type="text" name="maxday" value="${param.maxday}"></td>
</tr>
</tr>
<tr>
<td>
<input type="submit" value="提交">
</td>
</tr>
</table>
</form>
</body>
</html>
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· 葡萄城 AI 搜索升级:DeepSeek 加持,客户体验更智能
· 什么是nginx的强缓存和协商缓存
· 一文读懂知识蒸馏