——————————DescriptionStart——————————
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明










基于javaweb的SSM在线考试系统(java+ssm+mysql+jsp+bootstrap)
老师:
teacher1 123456——管理员权限
teacher2 123456
teacher3 123456
学生:
student1 123456
student2 123456
student3 123456
——————————CodeStart——————————
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
| * 预修改教师 * @param teacherId * @return */ @RequestMapping(value="/teacher/{teacherId}", method=RequestMethod.GET) public ModelAndView preUpdateTeacher(@PathVariable("teacherId") Integer teacherId) { logger.info("预修改教师处理"); ModelAndView model = new ModelAndView(); TeacherInfo teacher = teacherInfoService.getTeacherById(teacherId); model.setViewName("/admin/teacheredit"); model.addObject("teacher", teacher); return model; }
@RequestMapping(value="/teacher/teacher", method=RequestMethod.POST) public String isUpdateOrAddTeacher(@RequestParam(value="teacherId", required=false) Integer teacherId, @RequestParam(value="isupdate", required=false) Integer isUpdate, @RequestParam("teacherName") String teacherName, @RequestParam("teacherAccount") String teacherAccount, @RequestParam("teacherPwd") String teacherPwd, @RequestParam("adminPower") Integer adminPower) { TeacherInfo teacher = new TeacherInfo(); teacher.setTeacherId(teacherId); teacher.setTeacherName(teacherName); teacher.setTeacherAccount(teacherAccount); teacher.setTeacherPwd(teacherPwd); teacher.setAdminPower(adminPower); if (isUpdate != null) { logger.info("修改教师 "+teacher+" 的信息"); int row = teacherInfoService.isUpdateTeacherInfo(teacher); } else { logger.info("添加教师 "+teacher+" 的信息"); int row = teacherInfoService.isAddTeacherInfo(teacher); }
|
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
| @RequestMapping("/self/{studentId}") public ModelAndView selfInfo(@PathVariable("studentId") Integer studentId) { StudentInfo stu = studentInfoService.getStudentById(studentId); ModelAndView model = new ModelAndView(); model.setViewName("/reception/self"); model.addObject("self", stu); return model; }
@RequestMapping("/reset/{pwd}/{studentId}") public void isResetPwd( @PathVariable("pwd") String pwd, @PathVariable("studentId") Integer studentId, HttpServletResponse response) throws IOException { logger.info("学生 "+studentId+" 修改密码"); student.setStudentId(studentId); student.setStudentPwd(pwd); int row = studentInfoService.isResetPwdWithStu(student); if (row > 0) { response.getWriter().print("t"); } else { response.getWriter().print("f"); } } }
|
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
| } } catch (Exception e) { e.printStackTrace(); } }
private void dispatcherExamPaperAndSubject(List<SubjectInfo> subjects, Integer examPaperId) { List<Integer> subjectIds = new ArrayList<Integer>(); int count = 0; int score = 0;
for (SubjectInfo subjectInfo : subjects) { int row1 = subjectInfoService.isAddSubject(subjectInfo); score += subjectInfo.getSubjectScore(); subjectIds.add(subjectInfo.getSubjectId()); count++; } logger.info("添加试题 SIZE " + count);
Map<String, Object> esmMap = new HashMap<String, Object>(); esmMap.put("examPaperId", examPaperId); esmMap.put("subjectIds", subjectIds); esmService.isAddESM(esmMap); logger.info("添加试题 SIZE " + count + " SCORE " + score + " 到试卷 " + examPaperId);
Map<String, Object> scoreWithNum = new HashMap<String, Object>(); scoreWithNum.put("subjectNum", count); scoreWithNum.put("score", score); scoreWithNum.put("examPaperId", examPaperId); examPaperInfoService.isUpdateExamPaperScore(scoreWithNum); examPaperInfoService.isUpdateExamPaperSubjects(scoreWithNum); }
|
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
| return "../error"; } return "redirect:/classes"; }
@RequestMapping(value="/gradeclass/{gradeId}", method=RequestMethod.GET) public void getClassesByGradeId(@PathVariable("gradeId") Integer gradeId, HttpServletResponse response) throws IOException { logger.info("获取年级 "+gradeId+" 下的班级集合"); List<ClassInfo> classes = classInfoService.getClassByGradeId(gradeId); String json = gson.toJson(classes); response.getWriter().print(json); }
private String isChangeTeacherWork(int status, Integer teacherId) { logger.info("修改教师 "+teacherId+" 的状态为 "+status); teacher.setIsWork(status); if (teacherId == null) { logger.error("修改教师班主任状态 对应教师编号有误"); return "修改教师班主任状态 对应教师编号有误"; } teacher.setTeacherId(teacherId); int row = teacherInfoService.updateTeacherIsWork(teacher); return null; }
@RequestMapping("/stuCount") public void getStudentCountForClass(
|
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
| * 返回学生密码,前台登录焦点离开密码框使用 JavaScript 判断 * * @param studentAccount 学生登录账户 * @param response * @throws IOException */ @RequestMapping("/validateLoginStudent") public void validateLoginStudent(@RequestParam("studentAccount") String studentAccount, HttpServletResponse response) throws IOException { logger.info("学生账户 "+studentAccount+",尝试登录考试"); StudentInfo student = studentInfoService.getStudentByAccountAndPwd(studentAccount); if (student == null) { logger.error("登录学生账户 "+studentAccount+" 不存在"); response.getWriter().print("n"); } else { logger.error("登录学生账户 "+studentAccount+" 存在"); response.getWriter().print(student.getStudentPwd()); } }
@RequestMapping(value="/studentLogin", method=RequestMethod.POST) public ModelAndView studentLogin(StudentInfo student, HttpServletRequest request) { ModelAndView model = new ModelAndView(); StudentInfo loginStudent = studentInfoService.getStudentByAccountAndPwd(student.getStudentAccount()); logger.info("学生 "+loginStudent+" 有效登录"); if(loginStudent == null || !student.getStudentPwd().equals(loginStudent.getStudentPwd())){ model.setViewName("reception/suc"); model.addObject("success", "密码错误"); return model; } request.getSession().setAttribute("loginStudent", loginStudent); model.setViewName("reception/suc"); model.addObject("success", "登录成功"); return model; }
|
——————————PayStart——————————
项目链接:
https://javayms.github.io?id=132123460509201em
https://javayms.pages.dev?id=132123460509201em