2000字范文,分享全网优秀范文,学习好帮手!
2000字范文 > Java项目:高中考试系统(java+SSM+Jsp+Mysql+Maven)

Java项目:高中考试系统(java+SSM+Jsp+Mysql+Maven)

时间:2019-01-01 19:38:58

相关推荐

Java项目:高中考试系统(java+SSM+Jsp+Mysql+Maven)

源码获取:博客首页 "资源" 里下载!

项目分为前台和后台,前台主要为学生角色、后台主要为管理员角色。

管理员添加试题和发布试卷,学生负责在线考试、在线查看成绩和错题记录列表等。

管理员功能有:年级管理、课程管理、试题管理、试卷管理、学生管理等。

运行环境:jdk1.8、mysql5.x、eclipse、tomcat8.5\7.0、maven3.5\3.6。

登录控制层:

@Controllerpublic class LoginController {@Autowiredprivate StudentService studentService;@Autowiredprivate TeacherService teacherService;@Autowiredprivate QuestionService questionService;@Autowiredprivate PaperService paperService;@Autowiredprivate ClasseService classeService;@Autowiredprivate RecordService recordService;@RequestMapping("/")public String view(Model model){//查询所有用户int teas=teacherService.queryCountAll();int stus=studentService.queryCOuntALlstu();int alllogers=teas+stus;//统计试题int allQues=questionService.queryCountAllQues();//统计试卷int allPaps=paperService.queryCountALlPaps();model.addAttribute("allPaps",allPaps);model.addAttribute("allQues",allQues);model.addAttribute("alllogers",alllogers);return "stage/prexam";}//后台切换到前台登录@RequestMapping("/foreLogin")public String foreLogin(){return "stage/login";}//前台切换到后台登录@RequestMapping("/backLogin")public String backLogin(){return "stage/loginx";}//后台教师登录验证@ResponseBody@RequestMapping("/backLogin/check")public Object backCheck(Teacher teacher, HttpServletRequest request){AjaxResult result=new AjaxResult();HttpSession session=request.getSession();Teacher teac=teacherService.check(teacher);if(teac!=null){session.setAttribute("logerd",teac);result.setSuccess(true);}else {result.setSuccess(false);}return result;}@RequestMapping("/index")public String index(Model model){//查询所有用户int teas=teacherService.queryCountAll();int stus=studentService.queryCOuntALlstu();int alllogers=teas+stus;//统计试题int allQues=questionService.queryCountAllQues();//统计试卷int allPaps=paperService.queryCountALlPaps();List<Record> ScoreHStu=recordService.queryRankScoreRecord();List<Record> AccHStu=recordService.queryRankAccRecord();model.addAttribute("ScoreHStu",ScoreHStu);model.addAttribute("AccHStu",AccHStu);model.addAttribute("allPaps",allPaps);model.addAttribute("allQues",allQues);model.addAttribute("alllogers",alllogers);return "index";}//前台学生登录考试@ResponseBody@RequestMapping("/foreCheck/check")public Object foreCheck(Student student, HttpServletRequest request){AjaxResult result=new AjaxResult();HttpSession session=request.getSession();Student stud=studentService.check(student);if(stud!=null){session.setAttribute("loger",stud);result.setSuccess(true);}else {result.setSuccess(false);}return result;}//前台登录到展示页面@RequestMapping("/indexprexam")public String indexprexam(){return "stage/prexamed";}//退出系统@RequestMapping(value = {"*/logout","/logout","teacher/logout"})public String logout(HttpSession session) {//session里可能不止存放一个数据,移除麻烦,所以让其失效跟直接session.invalidate();return "redirect:/";}//学生注册//去添加页面@RequestMapping("/prexam/toAddStudent")public String toAddStudent(Model model){List<Classe> allClasees = classeService.getAll();model.addAttribute("allClasees",allClasees);return "stage/studentAdd";}//添加具体操作@RequestMapping("/prexam/AddStudent")public String AddStudent(Student student){studentService.AddStudent(student);return "redirect:/foreLogin";}@RequestMapping("/zhao")public String zhao(){return "stage/zhao";}}

学生管理控制层:

@Controller@RequestMapping("/student")public class StudentController {@Autowiredprivate ClasseMapper classeMapper;@Autowiredprivate StudentService studentService;//查看所有学生@RequestMapping("/getAllStudent")public String getAllStudent(Model model){List<Student> students = studentService.getAll();model.addAttribute("students",students);return "student/studentList";}//修改编辑功能,先获取该id得学生信息@RequestMapping("/{id}")public String updateStudent(@PathVariable("id") Integer id,Model model){Student student=studentService.getStudentById(id);List<Classe> classes = classeMapper.queryAll();model.addAttribute("classes",classes);model.addAttribute("student",student);return "student/studentEdit";}//更改学生信息@RequestMapping("/editStudent")public String EditStudent(Student student){studentService.EditStudent(student);return "redirect:/student/getAllStudent";}//删除学生@RequestMapping("/deleteStudent/{id}")public String deleteStudent(@PathVariable("id") Integer id){studentService.deleteById(id);return "redirect:/student/getAllStudent";}}

问题管理控制层:

@Controller@RequestMapping("/question")public class QuestionController {@Autowiredprivate QuestionService questionService;@Autowiredprivate TeacherService teacherService;@Autowiredprivate PaperService paperService;//查看所有试题 pagesize控制每页数据条数@RequestMapping("/getAllQuestion")public String getAllQuestion(Question question,@RequestParam(defaultValue = "1") int pageNum,@RequestParam(defaultValue = "4") int pageSize,Model model){//查找所有题目课程和所有类型,且去重List<Question> questionCourses=questionService.queryAllCourse();questionCourses.add(new Question("bug","all"));List<Question> questionTypes=questionService.queryAllType();questionTypes.add(new Question("k","bug"));String questionCourseBef = question.getQuestionCourse();String questionCourseresRes="";if(questionCourseBef==null){//默认查询所有questionCourseresRes="all";}else {questionCourseresRes=questionCourseBef;}//若是第一次查询则用上次提交的表单中的类型、课程,若是第二次查询则延用上次类型String questionTypeBef=question.getQuestionType();String questionTypesRes="";if(questionTypeBef==null){//默认查询所有questionTypesRes="k";}else {questionTypesRes=questionTypeBef;}List<Question> questionids=paperService.queryALlQuestionId();List<Integer> quesIds=new ArrayList<>();for(Question qid:questionids){quesIds.add(qid.getQuestionId());}model.addAttribute("quesIds",quesIds);PageHelper.startPage(pageNum,pageSize);//这行是重点,表示从pageNum页开始,每页pageSize条数据List<Question> questions = questionService.getAll(question);PageInfo<Question> pageInfo = new PageInfo<Question>(questions);model.addAttribute("questionCourseresRes",questionCourseresRes);model.addAttribute("questionTypesRes",questionTypesRes);model.addAttribute("questionTypes",questionTypes);model.addAttribute("questionCourses",questionCourses);model.addAttribute("pageInfo",pageInfo);return "question/questionList";}//试题添加或者修改操作,先去添加页面@RequestMapping("/toAddQuestion")public String toAddQuestion(Model model){List<Question> questionCourses=questionService.queryAllCourse();List<Question> questionTypes=questionService.queryAllType();model.addAttribute("questionTypes",questionTypes);model.addAttribute("questionCourses",questionCourses);return "question/questionAdd";}//添加具体操作@RequestMapping("/addQuestion")public String addQuestion(Question question){questionService.addQuestion(question);return "redirect:/question/getAllQuestion";}//试题去修改页面@RequestMapping("/toEditQuestion/{id}")public String toEditQuestion(@PathVariable("id") Integer id,Model model){List<Question> questionCourses=questionService.queryAllCourse();List<Question> questionTypes=questionService.queryAllType();Question question=questionService.getQuestionById(id);model.addAttribute("questionTypes",questionTypes);model.addAttribute("questionCourses",questionCourses);model.addAttribute("question",question);return "question/questionEdit";}//修改具体操作@RequestMapping("/EditQuestion")public String EditQuestion(Question question){questionService.editQuestion(question);return "redirect:/question/getAllQuestion";}//试题删除@RequestMapping("/deleteQuestion/{id}")public String deleteQuestionById(@PathVariable("id") Integer id){questionService.deleteQuestionById(id);return "redirect:/question/getAllQuestion";}}

源码获取:博客首页 "资源" 里下载!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。