Java项目:105Javaweb学生成绩管理系统(含论文)

发布时间:2024年01月02日

博主主页:Java旅途
简介:分享计算机知识、学习路线、系统源码及教程
文末获取源码

一、项目介绍

学生成绩管理系统使用原生的java技术开发,通过sevlet+jsp来实现前后端数据交互,通过jdbc进行数据存储。系统分为三种角色,分别是管理员,教师,学生。

超级管理员功能如下:

  • 课程管理
  • 班级管理
  • 年级管理
  • 教师管理
  • 学生管理
  • 考试管理
  • 成绩统计

教师功能如下:

  • 成绩登记
  • 教师通讯录

学生功能如下:

  • 班级通讯论
  • 成绩查询

二、技术框架

  • 后端:jdbc,sevlet
  • 前端:jsp

三、安装教程

  1. 用idea打开项目
  2. 在idea中配置jdk环境
  3. 配置tomcat8.0
  4. 新建数据库,导入数据库文件
  5. 在c3p0-config.xml文件中将数据库账号密码改成自己本地的
  6. 启动运行, 管理员账号密码 admin/123456 ,教师账号密码:2012/123456,学生账号密码:201402011/123456

四、项目截图

image-20230710164920759

image-20230710164949045

image-20230710165004133

image-20230710165018525

image-20230710165032551

image-20230710165055918

image-20230710165144098

五、相关代码

ExamServlet

package com.lizhou.servlet;

import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.beanutils.BeanUtils;

import com.lizhou.bean.Clazz;
import com.lizhou.bean.Exam;
import com.lizhou.bean.Grade;
import com.lizhou.bean.Page;
import com.lizhou.bean.Student;
import com.lizhou.bean.Teacher;
import com.lizhou.bean.User;
import com.lizhou.service.ExamService;
import com.lizhou.service.StudentService;
import com.lizhou.service.TeacherService;
import com.lizhou.tools.StringTool;

import net.sf.json.JSONObject;

/**
 * 考试类Servlet
 * 
 *
 */
public class ExamServlet extends HttpServlet {
	
	//创建服务层对象
	private ExamService service = new ExamService();
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//获取请求的方法
		String method = request.getParameter("method");
		if("toExamListView".equalsIgnoreCase(method)){ //转发到考试列表页
			request.getRequestDispatcher("/WEB-INF/view/other/examList.jsp").forward(request, response);
		}
	}
	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//获取请求的方法
		String method = request.getParameter("method");
		//请求分发
		if("ExamList".equalsIgnoreCase(method)){ //获取所有考试数据
			examList(request, response);
		} else if("AddExam".equalsIgnoreCase(method)){ //添加考试
			addExam(request, response);
		} else if("DeleteExam".equalsIgnoreCase(method)){ //删除考试信息
			deleteExam(request, response);
		} else if("TeacherExamList".equalsIgnoreCase(method)){ //获取属于某个老师的考试
			teacherExamList(request, response);
		} else if("StudentExamList".equalsIgnoreCase(method)){ //获取属于某个学生的考试
			studentExamList(request, response);
		}
		
		
		
	}
	
	private void studentExamList(HttpServletRequest request, HttpServletResponse response) throws IOException {
		//获取当前用户
		User user = (User) request.getSession().getAttribute("user");
		String number = user.getAccount();
		
		String result = service.studentExamList(number);
		response.getWriter().write(result);
	}

	private void teacherExamList(HttpServletRequest request, HttpServletResponse response) throws IOException {
		//获取当前用户
		User user = (User) request.getSession().getAttribute("user");
		String number = user.getAccount();
		String result = service.teacherExamList(number);
		response.getWriter().write(result);
	}

	private void deleteExam(HttpServletRequest request, HttpServletResponse response) throws IOException {
		//获取要删除的id
		int id = Integer.parseInt(request.getParameter("id"));
		try {
			service.deleteExam(id);
			response.getWriter().write("success");
		} catch (Exception e) {
			response.getWriter().write("fail");
			e.printStackTrace();
		}
	}

	private void addExam(HttpServletRequest request, HttpServletResponse response) throws IOException {
		//获取参数名
		Enumeration<String> pNames = request.getParameterNames();
		Exam exam = new Exam();
		while(pNames.hasMoreElements()){
			String pName = pNames.nextElement();
			String value = request.getParameter(pName);
			try {
				BeanUtils.setProperty(exam, pName, value);
			} catch (IllegalAccessException | InvocationTargetException e) {
				e.printStackTrace();
			}
		}
		try {
			service.addExam(exam);
			response.getWriter().write("success");
		} catch (Exception e) {
			response.getWriter().write("fail");
			e.printStackTrace();
		}
	}

	private void examList(HttpServletRequest request, HttpServletResponse response) throws IOException {
		//获取分页参数
		int page = Integer.parseInt(request.getParameter("page"));
		int rows = Integer.parseInt(request.getParameter("rows"));
		
		//年级ID
		String gradeid = request.getParameter("gradeid");
		//班级ID
		String clazzid = request.getParameter("clazzid");
		
		Exam exam = new Exam();
		
		if(!StringTool.isEmpty(gradeid)){
			exam.setGradeid(Integer.parseInt(gradeid));
		}
		if(!StringTool.isEmpty(clazzid)){
			exam.setClazzid(Integer.parseInt(clazzid));
		}
		
		//获取数据
		String result = service.getExamList(exam, new Page(page, rows));
		//返回数据
        response.getWriter().write(result);
	}
	
}

ScoreServlet


package com.lizhou.servlet;

import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.beanutils.BeanUtils;

import com.lizhou.bean.Clazz;
import com.lizhou.bean.Exam;
import com.lizhou.bean.Grade;
import com.lizhou.bean.Page;
import com.lizhou.bean.Student;
import com.lizhou.bean.Teacher;
import com.lizhou.service.ExamService;
import com.lizhou.service.ScoreService;
import com.lizhou.service.StudentService;
import com.lizhou.service.TeacherService;
import com.lizhou.tools.StringTool;

import net.sf.json.JSONObject;

/**
 * 成绩类Servlet
 * 
 *
 */
public class ScoreServlet extends HttpServlet {
	
	//创建服务层对象
	private ScoreService service = new ScoreService();
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//获取请求的方法
		String method = request.getParameter("method");
		//请求分发
		if("ExportScore".equalsIgnoreCase(method)){ //导出成绩
			exportScore(request, response);
		}
	}
	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//获取请求的方法
		String method = request.getParameter("method");
		//请求分发
		if("ScoreList".equalsIgnoreCase(method)){ //获取所有成绩数据
			scoreList(request, response);
		} else if("ColumnList".equalsIgnoreCase(method)){ //获取列
			columnList(request, response);
		} else if("SetScore".equalsIgnoreCase(method)){ //登记成绩
			setScore(request, response);
		} 
		
		
		
	}
	
	private void setScore(HttpServletRequest request, HttpServletResponse response) throws IOException {
		String[] score = request.getParameterValues("score[]");
		service.setScore(score);
		//返回数据
        response.getWriter().write("success");
	}
	
	private void exportScore(HttpServletRequest request, HttpServletResponse response) {
		//获取分页参数
		Enumeration<String> pNames = request.getParameterNames();
		Exam exam = new Exam();
		while(pNames.hasMoreElements()){
			String pName = pNames.nextElement();
			String value = request.getParameter(pName);
			try {
				BeanUtils.setProperty(exam, pName, value);
			} catch (IllegalAccessException | InvocationTargetException e) {
				e.printStackTrace();
			}
		}
		
		service.exportScore(response, exam);
	}
	
	private void columnList(HttpServletRequest request, HttpServletResponse response) throws IOException {
		Enumeration<String> pNames = request.getParameterNames();
		Exam exam = new Exam();
		while(pNames.hasMoreElements()){
			String pName = pNames.nextElement();
			String value = request.getParameter(pName);
			try {
				BeanUtils.setProperty(exam, pName, value);
			} catch (IllegalAccessException | InvocationTargetException e) {
				e.printStackTrace();
			}
		}
		
		//获取数据
		String result = service.columnList(exam);
		//返回数据
        response.getWriter().write(result);
	}
	
	private void scoreList(HttpServletRequest request, HttpServletResponse response) throws IOException {
		Enumeration<String> pNames = request.getParameterNames();
		Exam exam = new Exam();
		while(pNames.hasMoreElements()){
			String pName = pNames.nextElement();
			String value = request.getParameter(pName);
			try {
				BeanUtils.setProperty(exam, pName, value);
			} catch (IllegalAccessException | InvocationTargetException e) {
				e.printStackTrace();
			}
		}
		
		//获取数据
		String result = service.getScoreList(exam);
		//返回数据
        response.getWriter().write(result);
	}
	
}

大家点赞、收藏、关注、评论啦 、👇🏻点开下方卡片👇🏻关注后回复 101

文章来源:https://blog.csdn.net/m0_37968982/article/details/135334275
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。