学完java web后,期末期间用所学知识写了一个简单的学生管理系统,现在有空整理分享下。
注意:本文章仅供参考和学习,源码和数据库设计在文章的底部,点击展开然后往下翻就可以找到,其实数据库就六张表,很简单,可以看尾部第11项 数据实例表 自己写。导入报异常可能是导包的问题,BUG千千万,原因很多种,自己复制下eclipse报的错误报告,然后百度一下,基本能解决,因为我们现在遇到的错误,很多前人已经遇到并解决了,或者找身边的大佬帮忙看看。我只偶尔上线,做课程设计应急的话请直接点击链接下载,想学到东西的建议跟着文章自己写一写。
2020-05-17更新:好多人私信我要代码,我以为传到CSDN的盘上你们都能拿到的,但看见CSDN的积分要求越来越高,我就知道大伙搞不定了。我比较讨厌不劳而获,直接拿着项目跑结果的行为,但考虑的部分人在复现时确实存在着些许问题,可能是我博客写的不够好的原因吧,所以现在我重新上传至百度网盘,供大家下载,希望大家能在这基础上做一些改进,比如说数据库写的很烂,你们可以写一些视图、存储过程等,功能上也可以作进一步的优化,前端也可以做的更精致……但别问我技术问题,这个课设项目做完后我没有去维护,一些原因下,我也不想去改bug。
链接:https://pan.baidu.com/s/1xRonKzSeIuEK7JEn6rvhzA
提取码:4pgr
复制这段内容后打开百度网盘手机App,操作更方便哦
1.简述
编写该系统的目的是为了对学生的成绩进行信息化管理,降低教师管理的成本,提高工作效率。该系统有六张数据表:学生表、教师(管理员)表、成绩表、课程表、班级表、登录表。学生表和教师表用来存储系统用户;成绩表用来存储学生成绩;课程表用来储存课程信息;班级表用来存储班级信息;登录表用来存储登录信息。该系统使用了MVC设计模式,实现了权限管理、登录登出、自动登录、验证码,成绩的增加、删除、修改、查询等功能。数据库使用的是mysql8.0,数据库的版本不同,那么连接驱动和连接方式也有所不同。
2.流程图
2.1登录
2.2管理员界面
2.3学生界面
3.项目目录
3.1项目目录图
3.2项目目录结构
3.3MVC模式
4.技术说明
4.1 权限管理
本系统的使用者分为两种:学生和管理员(教师)。权限管理分为数据权限、页面权限、功能权限。数据权限是控制用户看那些数据;页面权限是控制用户可以进入哪些页面;功能权限是控制用户可以使用哪些功能。这些权限的实现通过:EequesDispatch接口中的forward()进行请求转发技术、HttpServletResponse接口中的sendRedirect()进行重定向技术、HttpSession接口进行传参技术、EL表达式中隐式对象PageContest和SessionScope、JSTL中Core标签库的
4.2 登录登出
登录登出功能的实现主要运用了Session、Cookie技术。登录操作:当JSP的From表单提交相关的数据后,Servlet类会对提交的账号、密码、验证码、身份进行判断,通过对数据库中相关表单查询的得出结果。如果结果正确,则会将用户的状态user存入session域,接着发送一个用户的Cookie给浏览器,最后自动跳转到首页,否则会提示相应的错误提示。登出操作:首先是session对象无效,然后删除自动登录的Cookie,最后跳转至登陆界面。
4.3自动登录
自动登录技术的实现,运用了Cookie会话、Filter过滤器等技术。单一的使用Cookie也可以实现自动登录,但这样做会造成每个Servlet类中出现大量重复的校验程序,所以加入Filter对服务器的所有请求进行拦截。Filter会对用户的访问请求进行拦截,判断请求是否包含用户自动登录的Cookie。如果包含,则获取Cookie中的用户名、密码、身份,并验证用户名、密码、身份是否正确。如果正确,则将用户的登录信息封装到User对象存入Session域中,完成自动登录,完成自动登录
4.4验证码
验证码技术的实现,主要运用了Session技术。先产生4位随机数和图片,然后将图像以字节流的形式输出至客户端,最后把随机数存储至Session域中。
4.5成绩的增删改查
增、删、查、改的实现,主要运用了Java数据库连接技术。我使用的是MySQL。在与数据库连接前,需要安装MySQL的连接驱动jar包,然后注册数据库驱动,最后通过DiverManager获取数据库Connection连接对象。连接成功后再获取Statement状态对象,然后就可以使用Statement对象进行数据库的操作。对于查询操作的结果,运用ResultSet对象进行存储。
5Controller包下的类
5.1AddScoreServlet类
package Controller;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import Dao.AdministratorDao;
import Dao.ClassesDao;
import Dao.CourseDao;
import Dao.GradeDao;
import Dao.StudentDao;
import Model.Administrator;
import Model.Classes;
import Model.Course;
import Model.Grade;
import Model.Student;
/**
* Servlet implementation class AddScoreServlet
*/
public class AddScoreServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=utf-8");
String stuId = request.getParameter("stuId");
String stuName = request.getParameter("stuName");
String courseId = request.getParameter("courseId");
String tcId = request.getParameter("tcId");
String courseGrade = request.getParameter("courseGrade");
String classId = request.getParameter("classId");
try{
StudentDao stuDao = new StudentDao();
CourseDao courseDao = new CourseDao();
AdministratorDao adminDao = new AdministratorDao();
ClassesDao classesDao = new ClassesDao();
GradeDao gradeDao = new GradeDao();
Student stu = stuDao.find(stuId);
Course course = courseDao.find(courseId);
Administrator admin = adminDao.find(tcId);
Classes classes = classesDao.find(classId);
Grade grade = new Grade();
grade.setStuId(stuId);
grade.setStuName(stuName);
grade.setCourseId(courseId);
grade.setTcId(tcId);
grade.setCourseGrade(courseGrade);
grade.setClassId(classId);
if (stu.getStuName() == null) {
request.setAttribute("errerMsg", "姓名为空");
request.getRequestDispatcher("/Jsp/AddScore.jsp").forward(request, response);
}
if(stu != null || stu.getStuName() == stuName){
if(course != null){
if(admin != null){
if(classes != null){
if(gradeDao.insert(grade)){
response.sendRedirect(request.getContextPath() + "/Jsp/AddScore.jsp");
}else{
request.setAttribute("errerMsg", "添加失败");
request.getRequestDispatcher("/Jsp/AddScore.jsp").forward(request, response);
}
}else{
request.setAttribute("errerMsg", "没有该班级");
request.getRequestDispatcher("/Jsp/AddScore.jsp").forward(request, response);
}
}else{
request.setAttribute("errerMsg", "没有该教师ID");
request.getRequestDispatcher("/Jsp/AddScore.jsp").forward(request, response);
}
} else {
request.setAttribute("errerMsg", "没有该课程ID");
request.getRequestDispatcher("/Jsp/AddScore.jsp").forward(request, response);
}
}
} catch (Exception ee) {
ee.printStackTrace();
}
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request, response);
}
}
5.2AutoLoginFilter类
package Controller;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import Dao.AdministratorDao;
import Dao.StudentDao;
import Model.Administrator;
import Model.Student;
import Model.User;
/**
* Servlet Filter implementation class AutoLoginFilter
*/
public class AutoLoginFilter implements Filter {
/**
* @see Filter#destroy()
*/
public void destroy() {
// TODO Auto-generated method stub
}
/**
* @see Filter#doFilter(ServletRequest, ServletResponse, FilterChain)
*/
public void doFilter(ServletRequest req, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) req;
//获取一个名为autologin的cookie
Cookie[] cookies = request.getCookies();
String autologin = null;
for (int i=0; cookies != null && i
5.3CheckServlet类
package Controller;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.awt.*;
/**
* Servlet implementation class CheckServlet
*/
public class CheckServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private static int WIDTH = 60;
private static int HEIGHT = 20;
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
HttpSession session = request.getSession();
response.setContentType("image/jpeg");
ServletOutputStream sos = response.getOutputStream();
//设置浏览器不要缓存图片
response.setHeader("Pragma", "No-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 0);
//创建内存图像并获得其图形上下文
BufferedImage image = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_RGB);
Graphics g = image.getGraphics();
//产生随机的认证码
char[] rands = generateCheckCode();
//产生图片
drawBackground(g);
drawRands(g, rands);
//结束图像的绘制过程,完成图像
g.dispose();
//将图像输出到客户端
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ImageIO.write(image, "JPEG", bos);
byte[] buf = bos.toByteArray();
response.setContentLength(buf.length);
//下面语句也可写成:bos.writeTo(sos);
sos.write(buf);
bos.close();
sos.close();
//将当前验证码存入到Session中
session.setAttribute("check_code", new String(rands));
//直接使用下面的代码将有问题,session对象在提交响应前获取
// request.getSession().setAttribute("check_code", new String(rands));
}
private void drawRands(Graphics g, char[] rands) {
g.setColor(Color.BLACK);
g.setFont(new Font(null, Font.ITALIC|Font.BOLD, 18));
//在不同的高度上输出验证码的每个字符
g.drawString("" + rands[0], 1, 17);
g.drawString("" + rands[1], 16, 15);
g.drawString("" + rands[2], 31, 18);
g.drawString("" + rands[3], 46, 16);
System.out.println(rands);
}
private void drawBackground(Graphics g) {
//画背景
g.setColor(new Color(0xDCDCDC));
g.fillRect(0, 0, WIDTH, HEIGHT);
//随机产生120个干扰点
for (int i=0; i<120; i++)
{
int x = (int)(Math.random() * WIDTH);
int y = (int)(Math.random() * HEIGHT);
int red = (int)(Math.random() * 255);
int green = (int)(Math.random() * 255);
int blue= (int)(Math.random() * 255);
g.setColor(new Color(red, green, blue));
g.drawOval(x, y, 1, 0);
}
}
//生成一个4字符的验证码
private char[] generateCheckCode() {
//定义验证码的字符表
String chars = "0123456789zxcvbnmasdfghjklqwertyuiop";
char [] rands = new char[4];
for(int i=0; i<4; i++)
{
int rand = (int)(Math.random() * 36);
rands[i] = chars.charAt(rand);
}
return rands;
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request, response);
}
}
5.4DelScoreServlet类
package Controller;
import java.io.IOException;
import java.util.ArrayList;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import Dao.GradeDao;
import Model.Grade;
/**
* Servlet implementation class DelScoreServlet
*/
public class DelScoreServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=utf-8");
String stuId = request.getParameter("stuId");
String stuName = request.getParameter("stuName");
String courseId = request.getParameter("courseId");
String tcId = request.getParameter("tcId");
String classId = request.getParameter("classId");
String grade = request.getParameter("grade");
Grade grades = new Grade();
grades.setStuId(stuId);
grades.setStuName(stuName);
grades.setCourseId(courseId);
grades.setTcId(tcId);
grades.setClassId(classId);
grades.setCourseGrade(grade);
HttpSession session = request.getSession();
ArrayList list = (ArrayList) session.getAttribute("grade");
try {
GradeDao gradeDao = new GradeDao();
if (gradeDao.delete(grades)) {
for(int j=0;j
5.5ExitServlet类
package Controller;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import Model.User;
/**
* Servlet implementation class ExitServlet
*/
public class ExitServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
response.setContentType("text/html; charset=utf-8");
HttpSession session = request.getSession();
User user = (User)session.getAttribute("user");
System.out.println(user.getIdentity());
if(user.getIdentity().equals("student")){
session.removeAttribute("grade");
response.sendRedirect(request.getContextPath() + "/Jsp/Student.jsp");
}else{
session.removeAttribute("grade");
response.sendRedirect(request.getContextPath() + "/Jsp/Admin.jsp");
}
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request, response);
}
}
5.6FindScoreServlet类
package Controller;
import java.io.IOException;
import java.util.ArrayList;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import Dao.GradeDao;
import Dao.StudentDao;
import Model.Student;
import Model.User;
import Model.Grade;
/**
* Servlet implementation class FindScoreServlet
*/
public class FindScoreServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=utf-8");
HttpSession session = request.getSession();
User users = (User)request.getSession().getAttribute("user");
String id = null;
if (users.getIdentity() == "admin") {
id = request.getParameter("id");
} else if (users.getIdentity() == "student") {
id = users.getUsername();
}
String func = request.getParameter("func");
try {
StudentDao stuDao = new StudentDao();
Student student = stuDao.find(id);
if(student != null){
try {
GradeDao gradeDao = new GradeDao();
ArrayList list = (ArrayList) gradeDao.find(id);
session.setAttribute("grade", list);
if(func.equals("show")){
response.sendRedirect(request.getContextPath() + "/Jsp/FindScore.jsp");
}else{
response.sendRedirect(request.getContextPath() + "/Jsp/UpdDelScore.jsp");
}
} catch(Exception ee) {
ee.printStackTrace();
}
}else{
request.setAttribute("errerMsg", "没有该学生");
if(func.equals("show")){
request.getRequestDispatcher("/Jsp/FindScore.jsp").forward(request, response);
}else{
request.getRequestDispatcher("/Jsp/UpdDelScore.jsp").forward(request, response);
}
}
} catch (Exception ee) {
ee.printStackTrace();
}
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request, response);
}
}
5.7LoginServlet类
package Controller;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import Dao.AdministratorDao;
import Dao.StudentDao;
import Dao.UserDao;
import Model.Administrator;
import Model.Student;
import Model.User;
/**
* Servlet implementation class LoginServlet
*/
public class LoginServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=utf-8");
String username = request.getParameter("username");
String password = request.getParameter("password");
String identity = request.getParameter("identity");
String autoLogin = request.getParameter("autologin");
String checkCode = request.getParameter("check_code");
String savedCode = (String) request.getSession().getAttribute("check_code");
System.out.println(username + " " + password + " " + checkCode + " "
+ savedCode + " " + identity);
if(username != null && password != null){
System.out.println("账号密码不为空");
//账号密码不为空
if(checkCode.equals(savedCode)) {
//验证码正确
System.out.println("验证码正确");
if(identity !=null) {
if(identity.equals("admin")){ //教师
try{
System.out.println("进入教师");
AdministratorDao adminDao = new AdministratorDao();
Administrator admin = adminDao.find(username);
if (admin != null){
if (admin.getTcPassword().equals(password)) {
System.out.println("ok");
function1(username, password, autoLogin, 1, request, response);
}
} else {
request.setAttribute("errerMsg", "没有该教师");
request.getRequestDispatcher("/Jsp/Login.jsp").forward(request, response);
}
} catch (Exception ee) {
ee.printStackTrace();
}
} else if (identity.equals("student")){ //学生
try{
System.out.println("进入学生");
StudentDao stuDao = new StudentDao();
Student student = stuDao.find(username);
if (student != null) {
if (student.getStuPassword().equals(password)){
System.out.println("ok");
function1(username, password, autoLogin, 2, request, response);
}
} else {
request.setAttribute("errerMsg", "没有该学生");
request.getRequestDispatcher("/Jsp/Login.jsp").forward(request, response);
}
} catch (Exception ee) {
ee.printStackTrace();
}
}
} else {
request.setAttribute("errerMsg", "身份为空");
request.getRequestDispatcher("/Jsp/Login.jsp").forward(request, response);
}
} else {
//验证不正确
request.setAttribute("errerMsg", "验证码错误");
request.getRequestDispatcher("/Jsp/Login.jsp").forward(request, response);
}
} else {
//账号或密码为空
request.setAttribute("errerMsg", "用户名或密码不能为空");
request.getRequestDispatcher("/Jsp/Login.jsp").forward(request, response);
}
}
private void function1(String username, String password, String autoLogin, int num,
HttpServletRequest request, HttpServletResponse response) throws IOException{
//将用户状态user对象存入session域
User user = new User();
user.setUsername(username);
user.setPassword(password);
if (num == 1) {
user.setIdentity("admin");
} else if (num ==2) {
user.setIdentity("student");
}
request.getSession().setAttribute("user", user);
//登陆记录
UserDao userDao = new UserDao();
userDao.insert(user);
//发送自动登陆的cookie
if(autoLogin != null){
//注意cookie中的密码要加密
if(num == 1){
Cookie cookie = new Cookie("autologin", username + "-" + password + "-" + "1");
cookie.setMaxAge(Integer.parseInt(autoLogin));
cookie.setPath(request.getContextPath());
response.addCookie(cookie);
}else if (num == 2){
Cookie cookie = new Cookie("autologin", username + "-" + password + "-" + "2");
cookie.setMaxAge(Integer.parseInt(autoLogin));
cookie.setPath(request.getContextPath());
response.addCookie(cookie);
}
}
if (num == 1) { //教师
//跳转至首页
response.sendRedirect(request.getContextPath() + "/Jsp/Admin.jsp");
} else if (num == 2){ //学生
//跳转至首页
response.sendRedirect(request.getContextPath() + "/Jsp/Student.jsp");
}
}
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}
}
5.8LogoutServlet类
package Controller;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class LogoutServlet
*/
public class LogoutServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//用户注销
request.getSession().invalidate();
//从客户端删除自动登陆的cookie
Cookie cookie = new Cookie("autologin", "msg");
cookie.setPath(request.getContextPath());
cookie.setMaxAge(0);
response.addCookie(cookie);
response.sendRedirect(request.getContextPath() + "/Jsp/Login.jsp");
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request, response);
}
}
5.9UpdScoreServlet类
package Controller;
import java.io.IOException;
import java.util.ArrayList;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import Dao.GradeDao;
import Model.Grade;
/**
* Servlet implementation class UpdScoreServlet
*/
public class UpdScoreServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charcet=utf-8");
String stuId = request.getParameter("stuId");
String stuName = request.getParameter("stuName");
String courseId = request.getParameter("courseId");
String tcId = request.getParameter("tcId");
String classId = request.getParameter("classId");
String grade = request.getParameter("grade");
Grade grades = new Grade();
grades.setStuId(stuId);
grades.setStuName(stuName);
grades.setCourseId(courseId);
grades.setTcId(tcId);
grades.setClassId(classId);
grades.setCourseGrade(grade);
HttpSession session = request.getSession();
try{
GradeDao gradeDao = new GradeDao();
if (gradeDao.update(grades)) {
ArrayList list = (ArrayList) gradeDao.find(stuId);
session.setAttribute("grade", list);
response.sendRedirect(request.getContextPath() + "/Jsp/UpdDelScore.jsp");
} else {
request.setAttribute("errerMsg", "更新失败");
request.getRequestDispatcher("/Jsp/UpdDelScore.jsp").forward(request, response);
}
} catch(Exception ee) {
ee.printStackTrace();
}
}
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
6.Dao包下的类
6.1AdministratorDao类
package Dao;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import Model.Administrator;
import Util.JDBCUtils;
public class AdministratorDao {
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
//添加管理员操作
public boolean insert(Administrator admin){
try {
conn = JDBCUtils.getConnection();
stmt = conn.createStatement();
String sql = "insert into administrator (tcId, tcName, tcClassId, tcSex, tcPassword) "
+ "values('"
+ admin.getTcId()
+ "','"
+ admin.getTcName()
+ "','"
+ admin.getTcClassId()
+ "','"
+ admin.getTcSex()
+ "','"
+ admin.getTcPassword()
+ "')";
System.out.println("添加SQL语句为:" + sql);
int num = stmt.executeUpdate(sql);
if (num > 0){
return true;
}
return false;
} catch (Exception ee) {
ee.printStackTrace();
} finally {
JDBCUtils.release(rs, stmt, conn);
}
return false;
}
//查询所有的Administrator对象
public ArrayList findAll(){
ArrayList list = new ArrayList();
try{
conn = JDBCUtils.getConnection();
stmt = conn.createStatement();
String sql = "select * from administrator";
System.out.println("查询所有的SQL语句:" + sql);
rs = stmt.executeQuery(sql);
while (rs.next()) {
Administrator admin = new Administrator();
admin.setTcId(rs.getString("tcId"));
admin.setTcName(rs.getString("tcName"));
admin.setTcSex(rs.getString("tcSex"));
admin.setTcClassId(rs.getString("tcClassId"));
admin.setTcPassword(rs.getString("tcPassword"));
list.add(admin);
}
return list;
} catch(Exception ee) {
ee.printStackTrace();
} finally {
JDBCUtils.release(rs, stmt, conn);
}
return null;
}
//根据ID查询
public Administrator find(String tcId){
try{
conn = JDBCUtils.getConnection();
stmt = conn.createStatement();
String sql = "select * from administrator where tcId = '" + tcId +"'";
System.out.println("单个查询SQL语句:" + sql);
rs = stmt.executeQuery(sql);
while (rs.next()) {
Administrator admin = new Administrator();
admin.setTcId(rs.getString("TcId"));
admin.setTcName(rs.getString("TcName"));
admin.setTcSex(rs.getString("TcSex"));
admin.setTcClassId(rs.getString("TcClassId"));
admin.setTcPassword(rs.getString("TcPassword"));
return admin;
}
return null;
}catch(Exception ee){
ee.printStackTrace();
}finally{
JDBCUtils.release(rs, stmt, conn);
}
return null;
}
//删除学生
public boolean delete(String tcId){
try{
conn = JDBCUtils.getConnection();
stmt = conn.createStatement();
String sql = "delete from administrator where tcId= '" + tcId + "'";
System.out.println("删除的SQL语句是:" + sql);
int num = stmt.executeUpdate(sql);
if (num > 0){
return true;
}
return false;
} catch (Exception ee){
ee.printStackTrace();
} finally {
JDBCUtils.release(rs, stmt, conn);
}
return false;
}
//修改用户
public boolean update(Administrator admin){
try{
conn = JDBCUtils.getConnection();
stmt = conn.createStatement();
String sql = "update administrator set tcName='" + admin.getTcName()
+ "',tcClassId='" + admin.getTcClassId()
+ "',tcSex='" + admin.getTcSex()
+ "',tcPassword='" + admin.getTcPassword()
+ "' where tcId='" + admin.getTcId() + "'";
System.out.println("修改的SQL语句是:" + sql);
int num = stmt.executeUpdate(sql);
if (num > 0){
return true;
}
return false;
} catch (Exception ee){
ee.printStackTrace();
} finally {
JDBCUtils.release(rs, stmt, conn);
}
return false;
}
}
6.2ClassDao类
package Dao;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import Model.Classes;
import Util.JDBCUtils;
public class ClassesDao {
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
//添加班级操作
public boolean insert(Classes classes){
try {
conn = JDBCUtils.getConnection();
stmt = conn.createStatement();
String sql = "insert into classes (classId, stuNum, className) "
+ "values('"
+ classes.getClassId()
+ "',"
+ classes.getStuNum()
+ ",'"
+ classes.getClassName()
+ "')";
System.out.println("添加SQL语句为:" + sql);
int num = stmt.executeUpdate(sql);
if (num > 0){
return true;
}
return false;
} catch (Exception ee) {
ee.printStackTrace();
} finally {
JDBCUtils.release(rs, stmt, conn);
}
return false;
}
//查询所有的classes对象
public ArrayList findAll(){
ArrayList list = new ArrayList();
try{
conn = JDBCUtils.getConnection();
stmt = conn.createStatement();
String sql = "select * from classes";
System.out.println("查询所有的SQL语句:" + sql);
rs = stmt.executeQuery(sql);
while (rs.next()) {
Classes classes = new Classes();
classes.setClassId(rs.getString("classId"));
classes.setStuNum(rs.getInt("stuNum"));
classes.setClassName(rs.getString("className"));
list.add(classes);
}
return list;
} catch(Exception ee) {
ee.printStackTrace();
} finally {
JDBCUtils.release(rs, stmt, conn);
}
return null;
}
//根据ID查询
public Classes find(String classId){
try{
conn = JDBCUtils.getConnection();
stmt = conn.createStatement();
String sql = "select * from classes where classId = '" + classId + "'";
rs = stmt.executeQuery(sql);
System.out.println("单个查询SQL语句:" + sql);
while (rs.next()) {
Classes classes = new Classes();
classes.setClassId(rs.getString("classId"));
classes.setStuNum(rs.getInt("stuNum"));
classes.setClassName(rs.getString("className"));
return classes;
}
return null;
}catch(Exception ee){
ee.printStackTrace();
}finally{
JDBCUtils.release(rs, stmt, conn);
}
return null;
}
//删除班级
public boolean delete(String classId){
try{
conn = JDBCUtils.getConnection();
stmt = conn.createStatement();
String sql = "delete from classes where classId='" + classId + "'";
System.out.println("删除的SQL语句是:" + sql);
int num = stmt.executeUpdate(sql);
if (num > 0){
return true;
}
return false;
} catch (Exception ee){
ee.printStackTrace();
} finally {
JDBCUtils.release(rs, stmt, conn);
}
return false;
}
//修改班级
public boolean update(Classes classes){
try{
conn = JDBCUtils.getConnection();
stmt = conn.createStatement();
String sql = "update classes set stuNum=" + classes.getStuNum()
+ ",className='" + classes.getClassName()
+ "' where classId='" + classes.getClassId() +"'";
System.out.println("修改的SQL语句是:" + sql);
int num = stmt.executeUpdate(sql);
if (num > 0){
return true;
}
return false;
} catch (Exception ee){
ee.printStackTrace();
} finally {
JDBCUtils.release(rs, stmt, conn);
}
return false;
}
}
6.3CourseDao类
package Dao;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import Model.Course;
import Util.JDBCUtils;
public class CourseDao {
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
//添加课程操作
public boolean insert(Course course){
try {
conn = JDBCUtils.getConnection();
stmt = conn.createStatement();
String sql = "insert into course (courseId, courseTime, credit, courseName) "
+ "values('"
+ course.getCourseId()
+ "','"
+ course.getCourseTime()
+ "',"
+ course.getCredit()
+ ",'"
+ course.getCourseName()
+ "')";
System.out.println("添加SQL语句为:" + sql);
int num = stmt.executeUpdate(sql);
if (num > 0){
return true;
}
return false;
} catch (Exception ee) {
ee.printStackTrace();
} finally {
JDBCUtils.release(rs, stmt, conn);
}
return false;
}
//查询所有的course对象
public ArrayList findAll(){
ArrayList list = new ArrayList();
try{
conn = JDBCUtils.getConnection();
stmt = conn.createStatement();
String sql = "select * from course";
System.out.println("查询所有的SQL语句:" + sql);
rs = stmt.executeQuery(sql);
while (rs.next()) {
Course course = new Course();
course.setCourseId(rs.getString("courseId"));
course.setCourseName(rs.getString("courseName"));
course.setCredit(rs.getInt("credit"));
course.setCourseTime(rs.getString("CourseTime"));
list.add(course);
}
return list;
} catch(Exception ee) {
ee.printStackTrace();
} finally {
JDBCUtils.release(rs, stmt, conn);
}
return null;
}
//根据ID查询
public Course find(String courseId){
try{
conn = JDBCUtils.getConnection();
stmt = conn.createStatement();
String sql = "select * from course where courseId = '" + courseId + "'";
rs = stmt.executeQuery(sql);
System.out.println("单个查询SQL语句:" + sql);
while (rs.next()) {
Course course = new Course();
course.setCourseId(rs.getString("CourseId"));
course.setCourseName(rs.getString("CourseName"));
course.setCredit(rs.getInt("Credit"));
course.setCourseTime(rs.getString("CourseTime"));
return course;
}
return null;
}catch(Exception ee){
ee.printStackTrace();
}finally{
JDBCUtils.release(rs, stmt, conn);
}
return null;
}
//删除班级
public boolean delete(String courseId){
try{
conn = JDBCUtils.getConnection();
stmt = conn.createStatement();
String sql = "delete from course where courseId= '" + courseId + "'";
System.out.println("删除的SQL语句是:" + sql);
int num = stmt.executeUpdate(sql);
if (num > 0){
return true;
}
return false;
} catch (Exception ee){
ee.printStackTrace();
} finally {
JDBCUtils.release(rs, stmt, conn);
}
return false;
}
//修改班级
public boolean update(Course course){
try{
conn = JDBCUtils.getConnection();
stmt = conn.createStatement();
String sql = "update course set courseTime='" + course.getCourseTime()
+ "',credit=" + course.getCredit()
+ ",courseName='" + course.getCourseName()
+ "' where courseId='" + course.getCourseId() + "'";
System.out.println("修改的SQL语句是:" + sql);
int num = stmt.executeUpdate(sql);
if (num > 0){
return true;
}
return false;
} catch (Exception ee){
ee.printStackTrace();
} finally {
JDBCUtils.release(rs, stmt, conn);
}
return false;
}
}
6.4GradeDao类
package Dao;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import Model.Grade;
import Util.JDBCUtils;
public class GradeDao {
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
//添加成绩操作
public boolean insert(Grade grade){
try {
conn = JDBCUtils.getConnection();
stmt = conn.createStatement();
String sql = "insert into grade (stuId, stuName, courseId, tcId, courseGrade, classId) "
+ "values('"
+ grade.getStuId()
+ "','"
+ grade.getStuName()
+ "','"
+ grade.getCourseId()
+ "','"
+ grade.getTcId()
+ "','"
+ grade.getCourseGrade()
+ "','"
+ grade.getClassId()
+ "')";
System.out.println("添加SQL语句为:" + sql);
int num = stmt.executeUpdate(sql);
if (num > 0){
return true;
}
return false;
} catch (Exception ee) {
ee.printStackTrace();
} finally {
JDBCUtils.release(rs, stmt, conn);
}
return false;
}
//查询所有的grade对象
public ArrayList findAll(){
ArrayList list = new ArrayList();
try{
conn = JDBCUtils.getConnection();
stmt = conn.createStatement();
String sql = "select * from grade";
System.out.println("查询所有的SQL语句:" + sql);
rs = stmt.executeQuery(sql);
while (rs.next()) {
Grade grade = new Grade();
grade.setCourseId(rs.getString("courseId"));
grade.setStuName(rs.getString("stuName"));
grade.setCourseGrade(rs.getString("courseGrade"));
grade.setStuId(rs.getString("stuId"));
grade.setTcId(rs.getString("tcId"));
grade.setClassId(rs.getString("classId"));
list.add(grade);
}
return list;
} catch(Exception ee) {
ee.printStackTrace();
} finally {
JDBCUtils.release(rs, stmt, conn);
}
return null;
}
//根据ID查询
public ArrayList find(String stuId){
ArrayList list = new ArrayList();
try{
conn = JDBCUtils.getConnection();
stmt = conn.createStatement();
String sql = "select * from grade where stuId = '" + stuId + "'";
rs = stmt.executeQuery(sql);
System.out.println("单个查询SQL语句:" + sql);
while (rs.next()) {
Grade grade = new Grade();
grade.setCourseId(rs.getString("courseId"));
grade.setStuName(rs.getString("stuName"));
grade.setCourseGrade(rs.getString("courseGrade"));
grade.setStuId(rs.getString("stuId"));
grade.setTcId(rs.getString("tcId"));
grade.setClassId(rs.getString("classId"));
list.add(grade);
}
return list;
}catch(Exception ee){
ee.printStackTrace();
}finally{
JDBCUtils.release(rs, stmt, conn);
}
return null;
}
//删除成绩
public boolean delete(Grade grade){
try{
conn = JDBCUtils.getConnection();
stmt = conn.createStatement();
String sql = "delete from grade where stuId= '" + grade.getStuId()
+ "' and stuName = '" + grade.getStuName()
+ "' and courseId = '" + grade.getCourseId()
+ "' and tcId = '" + grade.getTcId()
+ "' and courseGrade = '" + grade.getCourseGrade()
+ "' and classId = '" + grade.getClassId()
+ "'";
System.out.println("删除的SQL语句是:" + sql);
int num = stmt.executeUpdate(sql);
if (num > 0){
return true;
}
return false;
} catch (Exception ee){
ee.printStackTrace();
} finally {
JDBCUtils.release(rs, stmt, conn);
}
return false;
}
//修改成绩
public boolean update(Grade grade){
try{
conn = JDBCUtils.getConnection();
stmt = conn.createStatement();
String sql = "update grade set "
+ "courseGrade='" + grade.getCourseGrade()
+ "' where stuId='" + grade.getStuId()
+"' and stuName= '" + grade.getStuName()
+"' and courseId='" + grade.getCourseId()
+"' and tcId='" + grade.getTcId()
+"' and classId='" + grade.getClassId()
+ "'";
System.out.println("修改的SQL语句是:" + sql);
int num = stmt.executeUpdate(sql);
if (num > 0){
return true;
}
return false;
} catch (Exception ee){
ee.printStackTrace();
} finally {
JDBCUtils.release(rs, stmt, conn);
}
return false;
}
}
6.5StudentDao类
package Dao;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import Model.Student;
import Util.JDBCUtils;
public class StudentDao {
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
//添加学生操作
public boolean insert(Student student){
try {
conn = JDBCUtils.getConnection();
stmt = conn.createStatement();
String sql = "insert into student (stuId, stuName, stuSex, stuClassId, stuPassword) "
+ "values('"
+ student.getStuId()
+ "','"
+ student.getStuName()
+ "','"
+ student.getStuSex()
+ "','"
+ student.getStuClassId()
+ "','"
+ student.getStuPassword()
+ "')";
System.out.println("添加SQL语句为:" + sql);
int num = stmt.executeUpdate(sql);
if (num > 0){
return true;
}
return false;
} catch (Exception ee) {
ee.printStackTrace();
} finally {
JDBCUtils.release(rs, stmt, conn);
}
return false;
}
//查询所有的student对象
public ArrayList findAll(){
ArrayList list = new ArrayList();
try{
conn = JDBCUtils.getConnection();
stmt = conn.createStatement();
String sql = "select * from student";
System.out.println("查询所有的SQL语句:" + sql);
rs = stmt.executeQuery(sql);
while (rs.next()) {
Student student = new Student();
student.setStuId(rs.getString("stuId"));
student.setStuName(rs.getString("stuName"));
student.setStuSex(rs.getString("stuSex"));
student.setStuClassId(rs.getString("stuClassId"));
student.setStuPassword(rs.getString("stuPassword"));
list.add(student);
}
return list;
} catch(Exception ee) {
ee.printStackTrace();
} finally {
JDBCUtils.release(rs, stmt, conn);
}
return null;
}
//根据ID查询
public Student find(String stuId){
try{
conn = JDBCUtils.getConnection();
stmt = conn.createStatement();
String sql = "select * from student where stuId = '" + stuId + "'";
rs = stmt.executeQuery(sql);
System.out.println("单个查询SQL语句:" + sql);
while (rs.next()) {
Student student = new Student();
student.setStuId(rs.getString("stuId"));
student.setStuName(rs.getString("stuName"));
student.setStuSex(rs.getString("stuSex"));
student.setStuClassId(rs.getString("stuClassId"));
student.setStuPassword(rs.getString("stuPassword"));
return student;
}
return null;
}catch(Exception ee){
ee.printStackTrace();
}finally{
JDBCUtils.release(rs, stmt, conn);
}
return null;
}
//删除学生
public boolean delete(String stuId){
try{
conn = JDBCUtils.getConnection();
stmt = conn.createStatement();
String sql = "delete from student where stuId='" + stuId + "'";
System.out.println("删除的SQL语句是:" + sql);
int num = stmt.executeUpdate(sql);
if (num > 0){
return true;
}
return false;
} catch (Exception ee){
ee.printStackTrace();
} finally {
JDBCUtils.release(rs, stmt, conn);
}
return false;
}
//修改用户
public boolean update(Student student){
try{
conn = JDBCUtils.getConnection();
stmt = conn.createStatement();
String sql = "update student set stuName='" + student.getStuName()
+ "',stuSex='" + student.getStuSex()
+ "',stuClassId='" + student.getStuClassId()
+ "',stuPassword='"+ student.getStuPassword()
+ "' where stuId='" + student.getStuId() + "'";
System.out.println("修改的SQL语句是:" + sql);
int num = stmt.executeUpdate(sql);
if (num > 0){
return true;
}
return false;
} catch (Exception ee){
ee.printStackTrace();
} finally {
JDBCUtils.release(rs, stmt, conn);
}
return false;
}
}
6.6UserDao类
package Dao;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import Model.User;
import Util.JDBCUtils;
public class UserDao {
//添加登录记录
public boolean insert(User user){
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try{
//获取数据的连接
conn = JDBCUtils.getConnection();
//获取Statement对象
stmt = conn.createStatement();
//发送SQL语句
String sql = "insert into user(username, password, identity)" +
"values('"
+ user.getUsername()
+ "','"
+ user.getPassword()
+ "','"
+ user.getIdentity()
+ "')";
int num = stmt.executeUpdate(sql);
if(num > 0){
return true;
}
return false;
} catch(Exception ee) {
ee.printStackTrace();
} finally{
JDBCUtils.release(rs, stmt, conn);
}
return false;
}
}
7.Model包下的类
7.1Administrator类
package Model;
public class Administrator {
private String tcId; //教师编号
private String tcName; //教师姓名
private String tcClassId; //班级编号
private String tcSex; //教师性别
private String tcPassword; //教师密码
public void setTcId(String tcId){
this.tcId = tcId;
}
public void setTcName(String tcName){
this.tcName = tcName;
}
public void setTcClassId(String tcClassId){
this.tcClassId = tcClassId;
}
public void setTcSex(String tcSex){
this.tcSex = tcSex;
}
public void setTcPassword(String tcPassWord){
this.tcPassword = tcPassWord;
}
public String getTcId(){
return tcId;
}
public String getTcName(){
return tcName;
}
public String getTcClassId(){
return tcClassId;
}
public String getTcSex(){
return tcSex;
}
public String getTcPassword(){
return tcPassword;
}
}
7.2Classes类
package Model;
public class Classes {
private String classId; //班级编号
private int stuNum; //学生数
private String className; //班级名
public void setClassId(String classId){
this.classId = classId;
}
public void setStuNum(int stuNum){
this.stuNum = stuNum;
}
public void setClassName(String className){
this.className = className;
}
public String getClassId(){
return classId;
}
public int getStuNum(){
return stuNum;
}
public String getClassName(){
return className;
}
}
7.3Course类
package Model;
public class Course {
private String courseId; //课程编号
private String courseTime; //课时
private int credit; //课程学分
private String courseName; //课程名
public void setCourseId(String courseId) {
this.courseId = courseId;
}
public void setCourseTime(String courseTime){
this.courseTime = courseTime;
}
public void setCredit(int credit){
this.credit = credit;
}
public void setCourseName(String courseName){
this.courseName = courseName;
}
public String getCourseId(){
return courseId;
}
public String getCourseTime(){
return courseTime;
}
public int getCredit(){
return credit;
}
public String getCourseName(){
return courseName;
}
}
7.4Grade类
package Model;
public class Grade {
private String stuId; //学生编号
private String stuName; //学生姓名
private String courseId; //课程编号
private String tcId; //教师
private String courseGrade; //课程分数
private String classId; //班级编号
public void setStuId(String stuId){
this.stuId = stuId;
}
public void setStuName(String stuName){
this.stuName = stuName;
}
public String getStuName(){
return stuName;
}
public void setCourseId(String courseId){
this.courseId = courseId;
}
public void setTcId(String tcId){
this.tcId = tcId;
}
public void setCourseGrade(String courseGrade){
this.courseGrade = courseGrade;
}
public void setClassId(String classId){
this.classId = classId;
}
public String getStuId(){
return stuId;
}
public String getCourseId(){
return courseId;
}
public String getTcId(){
return tcId;
}
public String getCourseGrade(){
return courseGrade;
}
public String getClassId(){
return classId;
}
}
7.5Student类
package Model;
public class Student {
private String stuId; //学生编号
private String stuName; //学生姓名
private String stuSex; //学生性别
private String stuClassId; //班级编号
private String stuPassword; //学生密码
public void setStuId(String stuId){
this.stuId = stuId;
}
public void setStuName(String stuName){
this.stuName = stuName;
}
public void setStuSex(String stuSex){
this.stuSex = stuSex;
}
public void setStuClassId(String stuClassId){
this.stuClassId = stuClassId;
}
public void setStuPassword(String stuPassword){
this.stuPassword = stuPassword;
}
public String getStuId(){
return stuId;
}
public String getStuName(){
return stuName;
}
public String getStuSex(){
return stuSex;
}
public String getStuClassId(){
return stuClassId;
}
public String getStuPassword(){
return stuPassword;
}
}
7.6User类
package Model;
public class User {
private String username; //账号
private String password; //密码
private String identity; //身份
public void setUsername(String username){
this.username = username;
}
public void setPassword(String password){
this.password = password;
}
public void setIdentity(String identity){
this.identity = identity;
}
public String getUsername(){
return username;
}
public String getPassword(){
return password;
}
public String getIdentity(){
return identity;
}
}
8.Utils包下的类
8.1JDBCUtils类
package Util;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class JDBCUtils {
// 加载驱动,并建立数据库连接
public static Connection getConnection() throws SQLException,
ClassNotFoundException {
Class.forName("com.mysql.cj.jdbc.Driver");
String url = "jdbc:mysql://localhost:3306/grademanage?useSSL=FALSE&serverTimezone=UTC"; //注意:8.0的MySQL,所以连接方式不一样
String Name = "root";
String password = "你的密码";
Connection conn = DriverManager.getConnection(url, Name, password);
return conn;
}
// 关闭数据库连接,释放资源
public static void release(Statement stmt, Connection conn) {
if (stmt != null) {
try {
stmt.close();
} catch (SQLException e) {
e.printStackTrace();
}
stmt = null;
}
if (conn != null) {
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
conn = null;
}
}
public static void release(ResultSet rs, Statement stmt,
Connection conn){
if (rs != null) {
try {
rs.close();
} catch (SQLException e) {
e.printStackTrace();
}
rs = null;
}
release(stmt, conn);
}
}
9.JSP
9.1 Login.jsp(登录界面)
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
学生成绩管理系统
用户登录
9.2 Student.jsp(学生操作界面)
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" import="java.util.*" import="Model.User"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
学生成绩管理系统
用户登录
学生操作界面
欢迎 ${sessionScope.user.username }!
注销
你无权访问!!!
用户登录
9.3 Foot.jsp(共有界面)
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" import="java.util.*" import="Model.User"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
学生成绩管理系统
用户登录
欢迎你,${sessionScope.user.username }!
注销
9.4 Admin.jsp (管理员操作界面)
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" import="java.util.*" import="Model.User"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
学生成绩管理系统
用户登录
管理员操作界面
欢迎 ${sessionScope.user.username }!
注销
你无权访问!!!
用户登录
9.5 AddScore.jsp(添加界面)
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" import="java.util.*"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
学生成绩管理系统-录入成绩
输入下列信息进行分数录入
<%@ include file="Foot.jsp" %>
你无权访问!!!
用户登录
9.6 FindScore.jsp(查询界面)
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" import="java.util.*" import="Model.Grade"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
学生成绩管理系统-查询成绩
用户登录
<%
ArrayList list=(ArrayList) session.getAttribute("grade");
if(list!=null&&list.size()!=0){%>
学号为<%=list.get(0).getStuId() %>的学生成绩如下
学生学号
学生姓名
课程编号
教师编号
课程分数
班级编号
<%
for(int j=0;j
<%=list.get(j).getStuId()%>
<%=list.get(j).getStuName()%>
<%=list.get(j).getCourseId()%>
<%=list.get(j).getTcId()%>
<%=list.get(j).getCourseGrade()%>
<%=list.get(j).getClassId()%>
<% }}%>
<%@ include file="Foot.jsp" %>
9.7 UpdScore.jsp(更新界面)
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" import="java.util.*" import="Model.Grade"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
学生成绩管理系统-修改删除成绩
<%
ArrayList list=(ArrayList) session.getAttribute("grade");
if(list!=null&&list.size()!=0){%>
学号为<%=list.get(0).getStuId() %>的学生成绩如下
学生学号
学生姓名
课程编号
教师编号
班级编号
课程分数
修改
是否删除
<%
for(int j=0;j
<%=list.get(j).getStuId()%>
<%=list.get(j).getStuName()%>
<%=list.get(j).getCourseId()%>
<%=list.get(j).getTcId()%>
<%=list.get(j).getClassId()%>
<% }}%>
<%@ include file="Foot.jsp" %>
你无权访问!!!
用户登录
10.系统演示
10.1登陆界面
10.2管理员操作界面
10.3管理员查询成绩界面
10.4管理员录入成绩界面
10.5管理员修改删除界面
10.6学生操作界面
10.7学生查询成绩界面
11 数据实体表
字段名 |
字段类型 |
是否为主键 |
是否为空 |
备注 |
courseID |
varchar(20) |
是 |
否 |
课程编号 |
courseTime |
varchar(20) |
否 |
否 |
课时 |
courseGrade |
int |
否 |
否 |
课程分数 |
courseName |
varchar(50) |
否 |
否 |
课程名 |
字段名 |
字段类型 |
是否为主键 |
是否为空 |
备注 |
stuID |
varchar(20) |
是 |
否 |
用户编号 |
courseID |
varchar(20) |
否 |
否 |
课程编号 |
teacher |
varchar(20) |
否 |
否 |
教师 |
courseGrade |
varchar(20) |
否 |
否 |
课程分数 |
classID |
varchar(20) |
否 |
否 |
班级编号 |
字段名 |
字段类型 |
是否为主键 |
是否为空 |
备注 |
classID |
varchar (20) |
是 |
否 |
班级编号 |
stuNum |
int |
否 |
否 |
学生数 |
className |
varchar(20) |
否 |
否 |
班级名 |
字段 |
字段类型 |
是否为主键 |
是否为空 |
备注 |
tcID |
varchar(20) |
是 |
否 |
教师编号 |
tcName |
varchar(20) |
否 |
否 |
教师姓名 |
tcClassID |
varchar(20) |
否 |
否 |
班级编号 |
tcSex |
varchar(20) |
否 |
否 |
教师性别 |
tcPassword |
varchar(20) |
否 |
否 |
教师密码 |
字段名 |
字段类型 |
是否为主键 |
是否为空 |
备注 |
stuID |
varchar(20) |
是 |
否 |
学生编号 |
stuName |
varchar(20) |
否 |
否 |
学生姓名 |
stuSex |
varchar(50) |
否 |
否 |
学生性别 |
stuClassID |
varchar(20) |
否 |
否 |
班级编号 |
stuPassword |
Varchar(20) |
否 |
否 |
学生密码 |
字段名 |
字段类型 |
是否为主键 |
是否为空 |
备注 |
username |
varchar(20) |
是 |
否 |
学生或教师的编号 |
password |
varchar(20) |
否 |
否 |
密码 |
identity |
varchar(20) |
否 |
否 |
身份 |
源码
数据库设计