Homework System
程序员文章站
2022-06-02 12:38:30
...
一.项目应用技术
jsp
spring boot
jpa
mysql
二.项目结构
mvc
三.项目原型及操作流程
系统登陆界面:
学生登陆:
教师登陆
教师操作界面:
添加学生作业
添加学生信息
显示学生提交的所有作业
学生操作界面:
学生登陆查看作业
提交作业
四.部分项目代码
作业提交:
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String id = req.getParameter(“id”);
System.out.println(id);
Homework homework = HomeworkJdbc.showHomeworkDetails(id);//访问数据库
req.setAttribute(“homework”,homework);
req.getRequestDispatcher(“jsp/submitHomework.jsp”).forward(req,resp); //展示内容
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
req.setCharacterEncoding("utf-8");
StudentHomework studentHomework = new StudentHomework();
studentHomework.setStudentId(Long.parseLong(req.getParameter("studentId")));
studentHomework.setHomeworkId(Long.parseLong(req.getParameter("homeworkId")));
studentHomework.setHomeworkTitle(req.getParameter("title"));
studentHomework.setHomeworkContent(req.getParameter("content"));
Date date = new Date();
studentHomework.setCreateTime(date);
boolean result = HomeworkJdbc.addStudentHomework(studentHomework);
req.setAttribute("isOK", result); //用于判断是否提交成功
req.setAttribute("type","addStudentHomework");
req.getRequestDispatcher("jsp/s_return.jsp").forward(req,resp);
}
数据库线程池:
public class DatabasePool {
private static HikariDataSource hikariDataSource;
//双重锁
public static HikariDataSource getHikariDataSource(){
if(null != hikariDataSource){
return hikariDataSource;
}
synchronized (DatabasePool.class) {
if (null != hikariDataSource) {
HikariConfig hikariConfig = new HikariConfig();
String driverName = "com.mysql.cj.jdbc.Driver";
hikariConfig.setUsername("root");
hikariConfig.setPassword("12345678");
hikariConfig.setDriverClassName(driverName);
hikariConfig.setJdbcUrl("jdbc:mysql://127.0.0.1:3306/test?serverTimezone=UTC");
hikariDataSource = new HikariDataSource(hikariConfig);
return hikariDataSource;
}
}
return null;
}
}
上一篇: 使用BURP抓包IOS
下一篇: Javaweb Homework
推荐阅读
-
PHP错误提示It is not safe to rely on the system……的解决方法
-
Android垃圾回收机制及程序优化System.gc
-
C#利用System.Threading.Thread.Sleep即时输出信息的详解
-
将字符串转换成System.Drawing.Color类型的方法
-
C#关于System.Collections空间详解
-
java基础(System.err和System.out)详解
-
ASP.NET邮件发送system.Net.Mail案例
-
.Net笔记:System.IO之Stream的使用详解
-
关于System.Convert的那些事儿
-
深入解析System.load 与 System.loadLibrary