定制小程序开发费用学生信息管理系统
一、系统介绍
软件环境
IDEA:2018.2
Java:jdk1.8
Mysql:8.0.13
Tomcat:8.5.23
系统功能
1.定制小程序开发费用管理员登录系统
2.定制小程序开发费用增加学生信息
3.定制小程序开发费用修改学生信息
3.定制小程序开发费用删除学生信息
4.查询学生信息
数据库涉及的表
admin
student
二、系统展示
1.登录系统
2.主页面
3.增加学生信息
4.修改学生信息
5.查询学生信息
三、代码实现
AdminDao
package com.sjsq.dao;import com.sjsq.vo.Admin;/** * @author shuijianshiqing * @date 2021/5/1 9:46 */public interface AdminDao { /** * 用户登录 * @param admin * @return */ public Admin login(Admin admin);}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
AdminDaoImpl
package com.sjsq.dao.impl;import com.sjsq.dao.AdminDao;import com.sjsq.utils.DBUtil;import com.sjsq.vo.Admin;import java.sql.Connection;import java.sql.PreparedStatement;import java.sql.ResultSet;import java.sql.SQLException;/** * @author shuijianshiqing * @date 2021/5/1 9:49 */public class AdminDaoImpl implements AdminDao { /** * 用户登录 * @param admin * @return */ @Override public Admin login(Admin admin) { Connection con = null; PreparedStatement ps = null; ResultSet rs = null; try { // 1.获取数据库连接 con = DBUtil.getConnection(); // 2.写sql String sql = "select * from admin where username = ? and password = ?"; // 3.预编译 ps = con.prepareStatement(sql); // 4.设置值 ps.setObject(1,admin.getUsername()); ps.setObject(2,admin.getPassword()); rs = ps.executeQuery(); Admin adminLogin = null; if(rs.next()){ adminLogin = new Admin(); // 从数据库中获取值到实体类的setter方法中 adminLogin.setUsername(rs.getString("username")); adminLogin.setPassword(rs.getString("password")); // 返回的是你查询出来的完整的对象 return adminLogin; } } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); }finally { // 关闭资源,避免出现异常 DBUtil.close(con,ps,rs); } return null; }}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
StudentDao
package com.sjsq.dao;import com.sjsq.vo.Student;import java.util.List;/** * @author shuijianshiqing * @date 2021/4/30 7:52 * * 学生信息接口 */public interface StudentDao { /** * 查询学生信息 * @param sql * @param arr * @return */ public List<Student> selectAll(String sql, Object[] arr); /** * 根据学号进行查询 * @param id * @return */ public Student selectStudent(Integer id); /** * 新增学生信息 * @param student * @return */ public boolean addStudent(Student student); /** * 修改学生信息 * @param student * @return */ public boolean updateStudent(Student student); /** * 删除学生信息 * @param id * @return */ public boolean deleteStudent(Integer id);}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
AdminService
package com.sjsq.service;import com.sjsq.vo.Admin;/** * @author shuijianshiqing * @date 2021/5/1 11:13 */public interface AdminService { /** * 用户登录 * @param admin * @return */ public Admin login(Admin admin);}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
AdminServiceImpl
package com.sjsq.service.impl;import com.sjsq.dao.AdminDao;import com.sjsq.dao.impl.AdminDaoImpl;import com.sjsq.service.AdminService;import com.sjsq.vo.Admin;/** * @author shuijianshiqing * @date 2021/5/1 11:13 */public class AdminServiceImpl implements AdminService { private AdminDao adminDao = new AdminDaoImpl(); @Override public Admin login(Admin admin) { return adminDao.login(admin); }}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
StudentService
package com.sjsq.service;import com.sjsq.vo.Student;import java.util.List;/** * @author shuijianshiqing * @date 2021/5/1 8:26 */public interface StudentService { /** * 查询学生信息 * @param student * @return */ public List<Student> selectAll(Student student); /** * 根据学号进行查询 * @param id * @return */ public Student selectStudent(Integer id); /** * 新增学生信息 * @param student * @return */ public boolean addStudent(Student student); /** * 修改学生信息 * @param student * @return */ public boolean updateStudent(Student student); /** * 删除学生信息 * @param id * @return */ public boolean deleteStudent(Integer id);}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
StudentServiceImpl
package com.sjsq.service.impl;import com.sjsq.dao.StudentDao;import com.sjsq.dao.impl.StudentDaoImpl;import com.sjsq.service.StudentService;import com.sjsq.vo.Student;import java.util.ArrayList;import java.util.List;/** * @author shuijianshiqing * @date 2021/5/1 8:26 */public class StudentServiceImpl implements StudentService { private StudentDao studentDao = new StudentDaoImpl(); @Override public List<Student> selectAll(Student student) { StringBuffer sql = new StringBuffer("select * from student where 1 = 1 "); List<Object> list = new ArrayList<Object>(); if(student != null){ // 根据id来查找对应的学生信息 if(student.getId() != null && student.getId() != 0){ sql.append(" and id = ?"); list.add(student.getId()); } } return studentDao.selectAll(sql.toString(),list.toArray()); } @Override public Student selectStudent(Integer id) { return studentDao.selectStudent(id); } @Override public boolean addStudent(Student student) { return studentDao.addStudent(student); } @Override public boolean updateStudent(Student student) { return studentDao.updateStudent(student); } @Override public boolean deleteStudent(Integer id) { return studentDao.deleteStudent(id); }}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
login.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %> <% // 获取绝对路径路径 ,开发项目一定要使用绝对路径,不然肯定出错 String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/"; %><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head> <base href="<%=basePath %>" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>用户登录</title> <style type="text/css"> h1{ text-align: center; } h4{ text-align: center;color: red; } body{ background-color: antiquewhite; } a{ text-decoration: none;font-size: 20px;color: black; } a:hover{ text-decoration: underline;font-size: 24px;color: red; } </style></head><body> <form action="check_login.jsp" method="post"> <h1>用户登录</h1> <hr/> <table align="center"> <tr> <td>账号:</td> <td><input type="text" name="username" placeholder="请输入您的账号" autofocus="autofocus"></td> </tr> <tr> <td>密码:</td> <td><input type="password" name="password" placeholder="请输入您的密码"></td> </tr> <tr> <td colspan="1"> </td> <td> <input type="submit" value="登录"/> <input type="reset" value="重置"/> </td> </tr> </table> </form></body></html>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
check_login.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %><%@ page import="com.sjsq.service.AdminService"%><%@ page import="com.sjsq.service.impl.AdminServiceImpl"%><%@ page import="com.sjsq.vo.Admin"%><% // 获取绝对路径路径 ,开发项目一定要使用绝对路径,不然肯定出错 String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head> <base href="<%=basePath %>" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>用户登录</title> <style type="text/css"> h1{ text-align: center; } h4{ text-align: center;color: red; } body{ background-color: antiquewhite; } </style></head><body> <h1>用户登录</h1> <hr> <% // 设置接收的编码为UTF-8 request.setCharacterEncoding("utf-8"); // 获取前端传过来的字符串 String username = request.getParameter("username"); String password=request.getParameter("password"); // 定义接受的对象 Admin admin = new Admin(); admin.setUsername(username); admin.setPassword(password); // 把数据库里面的Admin获取出来 AdminService adminService = new AdminServiceImpl(); // 注意数据的admin账号密码不能重复 Admin adminLogin = adminService.login(admin); System.out.println("显示登录用户信息:"); System.out.println(adminLogin); // 设置session session.setAttribute("admin",adminLogin); // 判断adminLogin是否为空 if(!(adminLogin==null)){ // 成功之后重定向到主页面 response.sendRedirect("main.jsp"); } else{ // 失败之后重定向到失败页面 response.sendRedirect("fail.jsp"); } %></body></html>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
logout.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %><html><head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>退出登录</title></head><body> <% // 会话失效 session.invalidate(); response.sendRedirect("login.jsp"); %></body></html>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
main.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %><%@ page import="com.sjsq.service.StudentService" %><%@ page import="com.sjsq.service.impl.StudentServiceImpl" %><%@ page import="com.sjsq.vo.Student" %><%@ page import="java.util.List" %><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>查看学生</title> <style type="text/css"> h1 { text-align: center; } body { background-color: antiquewhite; } th, td { width: 70px; height: 35px; text-align: center; } #before { text-align: center; } </style></head><body> <%-- 头部 --%> <jsp:include page="top.jsp"/><% // 设置获取注册时的编码为UTF-8 request.setCharacterEncoding("UTF-8"); StudentService studentService = new StudentServiceImpl(); // 定义一个学生类 Student student = new Student(); // 获取上一个页面传过来的值 if(request.getParameter("id")!=null && request.getParameter("id")!=""){ Integer id = Integer.parseInt(request.getParameter("id")); student.setId(id); } // 获取所有学生 List<Student> studentList = studentService.selectAll(student);%><h1>学生列表</h1><hr/><div id="before"> <form action="main.jsp" method="post"> 请输入姓名:<input type="text" name="id" placeholder="输入学号搜索"> <input type="submit" value="查询" /> </form></div><br><table align="center" cellspacing="0" align="center"> <tr bgcolor="#5f9ea0"> <th>学号</th> <th>姓名</th> <th>年龄</th> <th>性别</th> <th>民族</th> <th>省份</th> <th>专业</th> <th>班级</th> <th colspan="2">操作</th> </tr> <% for (int i = 0;i<studentList.size();i++){ Student s =studentList.get(i); %> <tr> <td><%=s.getId()%></td> <td><%=s.getName()%></td> <td><%=s.getAge()%></td> <td><%=s.getSex()%></td> <td><%=s.getNation()%></td> <td><%=s.getPlace()%></td> <td><%=s.getMajor()%></td> <td><%=s.getClasses()%></td> <td> <a href="update_student.jsp?id=<%=s.getId()%>">修改</a> <a href="delete_student.jsp?id=<%=s.getId()%>">删除</a> </td> </tr> <% } %></table><table align="center"> <tr> <td><a href="add_student.jsp">新增学生</a></td> </tr></table></body><%-- 底部 --%><jsp:include page="bottom.jsp"/></html>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
add_student.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %><html><head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>新增学生</title> <style type="text/css"> h1{ text-align: center; } body{ background-color: antiquewhite; } div{ text-align: center; } #before{ text-align: center; } </style></head><body> <%-- 头部 --%> <jsp:include page="top.jsp"/> <h1>新增学生</h1> <hr/> <div id="before"> <a href="javascript: window.history.go(-1)">返回上一级</a> </div> </br> <form action="do_add_student.jsp" method="post" name="addForm"> <div> <tr> <label>学号:</label> <input type="text" name="id" id="id" placeholder="学号" autofocus="autofocus"> </tr> </div> <div> <tr> <label>姓名:</label></td> <input type="text" name="name" id="name" placeholder="姓名"> </tr> </div> <div> <tr> <label>年龄:</label> <input type="text" name="age" id="age" placeholder="年龄"> </tr> </div> <div> <tr> <label>性别:</label> <input type="text" name="sex" id="sex" placeholder="性别"> </tr> </div> <div> <tr> <label>民族:</label> <input type="text" name="nation" id="nation" placeholder="民族"> </tr> </div> <div> <tr> <label>省份:</label> <input type="text" name="place" id="place" placeholder="省份"> </tr> </div> <div> <tr> <label>专业:</label> <input type="text" name="major" id="major" placeholder="专业"> </tr> </div> <div> <tr> <label>班级:</label> <input type="text" name="classes" id="classes" placeholder="班级"> </tr> </div> <br> <div id="submit"> <tr> <button type="submit" onclick="return checkForm()">添加</button> <button type="reset">重置</button> </tr> </div> </form> <script type="text/javascript"> function checkForm() { var id = addForm.id.value; var name = addForm.name.value; // 学号和姓名不能为空 if (id == "" || id == null) { alert("请输入学号"); addForm.id.focus(); return false; } else if (name == "" || name == null) { alert("请输入姓名"); addForm.name.focus(); return false; } alert('添加成功!'); return true; } </script> <%-- 底部 --%> <jsp:include page="bottom.jsp"/></body></html>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
- 108
- 109
- 110
- 111
- 112
- 113
- 114
- 115
- 116
- 117
update_student.jsp
<%@ page import="com.sjsq.service.StudentService" %><%@ page import="com.sjsq.service.impl.StudentServiceImpl" %><%@ page import="com.sjsq.vo.Student" %><%@ page contentType="text/html;charset=UTF-8" language="java" %><html><head> <title>修改学生</title> <style type="text/css"> h1{ text-align: center; } body{ background-color: antiquewhite; } div{ text-align: center; } #before{ text-align: center; } </style></head><body> <%-- 头部 --%> <jsp:include page="top.jsp"/> <h1>新增学生</h1> <hr/> <% //获取admin.jsp页面的bookid Integer id=Integer.parseInt(request.getParameter("id")); StudentService studentService = new StudentServiceImpl(); Student student = new Student(); student = studentService.selectStudent(id); %> <div id="before"> <a href="javascript: window.history.go(-1)">返回上一级</a> </div> </br> <form action="do_update_student.jsp" method="post" name="addForm"> <div> <tr> <label>学号:</label> <input type="text" name="id" id="id" placeholder="学号" value="<%=student.getId()%>" autofocus="autofocus"> </tr> </div> <div> <tr> <label>姓名:</label></td> <input type="text" name="name" id="name" placeholder="姓名" value="<%=student.getName()%>"> </tr> </div> <div> <tr> <label>年龄:</label> <input type="text" name="age" id="age" placeholder="年龄" value="<%=student.getAge()%>"> </tr> </div> <div> <tr> <label>性别:</label> <input type="text" name="sex" id="sex" placeholder="性别" value="<%=student.getSex()%>"> </tr> </div> <div> <tr> <label>民族:</label> <input type="text" name="nation" id="nation" placeholder="民族" value="<%=student.getNation()%>"> </tr> </div> <div> <tr> <label>省份:</label> <input type="text" name="place" id="place" placeholder="省份" value="<%=student.getPlace()%>"> </tr> </div> <div> <tr> <label>专业:</label> <input type="text" name="major" id="major" placeholder="专业" value="<%=student.getMajor()%>"> </tr> </div> <div> <tr> <label>班级:</label> <input type="text" name="classes" id="classes" placeholder="班级" value="<%=student.getClasses()%>"> </tr> </div> <br> <div id="submit"> <tr> <button type="submit" onclick="return checkForm()">修改</button> <button type="reset">重置</button> </tr> </div> </form> <script type="text/javascript"> function checkForm() { var id = addForm.id.value; var name = addForm.name.value; // 学号和姓名不能为空 if (id == "" || id == null) { alert("请输入学号"); addForm.id.focus(); return false; } else if (name == "" || name == null) { alert("请输入姓名"); addForm.name.focus(); return false; } alert('修改成功!'); return true; } </script> <%-- 底部 --%> <jsp:include page="bottom.jsp"/></body></html>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
- 108
- 109
- 110
- 111
- 112
- 113
- 114
- 115
- 116
- 117
- 118
- 119
- 120
- 121
- 122
- 123
- 124
- 125
- 126
- 127
四、其他
1.其他系统实现
JavaWeb系统系列实现
JavaSwing系统系列实现
2.获取源码
sql文件在sql目录下。
3.运行项目
4.备注
如有侵权请联系我删除。
5.支持博主
如果您觉得此文对您有帮助,请点赞加关注。祝您生活愉快!