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

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

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

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

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

登录控制层:

@Controller
public 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";}}

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

Java项目:在线高中考试系统(java+SSM+Jsp+Mysql+Maven)相关推荐

  1. Java项目:在线甜品商城系统(java+SSM+JSP+JavaScript+Mysql)

    源码获取:俺的博客首页 "资源" 里下载! 项目介绍 管理员角色包含以下功能: 管理员登录,套餐管理,甜品管理,预定管理等功能. 用户角色包含以下功能: 用户登录与注册,查看首页, ...

  2. Java项目:在线奶茶店系统(java+JSP+JavaScript+servlet+Mysql)

    源码获取:俺的博客首页 "资源" 里下载! 项目介绍 本系统分为前后台,分为普通用户和管理员两种角色: 管理员角色包含以下功能: 管理员登录,用户管理,分类管理,奶茶信息管理,订单 ...

  3. Java项目:在线点餐系统(java+Springboot+Maven+mybatis+Vue+mysql+Redis)

    源码获取:博客首页 "资源" 里下载! 项目描述: 这是一个基于SpringBoot+Vue框架开发的在线点餐系统.首先,这是一个前后端分离的项目.具有一个在线点餐系统该有的所有功 ...

  4. Java项目:在线宠物商店系统(java+SSM+mysql+maven+tomcat)

    源码获取:博客首页 "资源" 里下载! 一.项目简述 功能:本系统分用户前台和管理员后台. 系统包括用户的注册登录,狗狗的展示购物车添加以及下 单支付购买,后台有管理员用户,可以操 ...

  5. Java项目:在线美食网站系统(java+SSM+jsp+mysql+maven)

    源码获取:博客首页 "资源" 里下载! 一.项目简述 功能:用户的注册登录,美食浏览,美食文化,收藏百 科,趣味问答,食谱等等功能等等. 二.项目运行 环境配置: Jdk1.8 + ...

  6. Java项目:在线婚纱摄影预定系统(java+javaweb+SSM+springboot+mysql)

    源码获取:博客首页 "资源" 里下载! 一.项目简述 功能: 前后用户的登录注册,婚纱照片分类,查看,摄影师预 订,后台订单管理,图片管理等等. 二.项目运行 环境配置: Jdk1 ...

  7. Java项目:在线课程会员系统(java+Springboot+Maven+JSP+Spring+Mysql+layui)

    一.项目简述 功能包括: 用户管理,课程管理,在线视频观看,评论,会员展示,会员充值等等. 二.项目运行 环境配置: Jdk1.8 + Tomcat8.5 + mysql + Eclispe(Inte ...

  8. Java项目:在线蛋糕商城系统(java+jsp+jdbc+mysql)

    源码获取:博客首页 "资源" 里下载! 一.项目简述 功能: 主页显示热销商品:所有蛋糕商品展示,可进行商品搜 索:点击商品进入商品详情页,具有立即购买和加入购物 车功能,可增减购 ...

  9. Java项目:在线拍卖竞价系统(java+SpringBoot+FreeMarker+Mysql+redis)

    源码获取:博客首页 "资源" 里下载! 超级管理员:系统管理.用户管理(冻结等).审批竞拍标的物管理.竞标类型管理.审批机构.个人提现管理(审核).企业提现管理(审批)等. 普通用 ...

最新文章

  1. OC高效率52之理解消息转发机制
  2. 利用计算机技术执行去自动化,计算机技术和自动化的关系.doc
  3. 怀旧服湖畔镇服务器位置,《魔兽世界怀旧服》今天再开10组新服 47组服务器免费转服开启...
  4. java git服务器_Windows平台下Git服务器搭建
  5. 现代密码学1.4--现代密码的三大原则
  6. SpringBoot中整合Quartz
  7. linux驱动开发---并发控制
  8. leetcode 621. 任务调度器(贪心算法)
  9. FastDFS部署及测试
  10. 你的Parquet该升级了:IOException: totalValueCount == 0问题定位之旅
  11. CheckBoxList控件绑定数据和设置选定项
  12. postgresql保存图片_第一章 PostgreSQL中的数据库集群、数据库和表
  13. linux查看文件格式
  14. viper4android10段调节,VIPER HiFi怎么设置音效 音效调整技巧
  15. 【报告分享】笔记本行业营销洞察白皮-腾讯x京东(附下载)
  16. html获取qq高清头像
  17. 带栩字的优美古诗句_带栩字有寓意的男孩名字
  18. python对整数进行因数分解_浅谈将一个正整数分解质因数的逻辑思维和Python开发设计...
  19. Phoenix官方教程 (九) Channel
  20. 100个相见恨晚的Python库(建议收藏)

热门文章

  1. centos 自定义内核模块 编译运行
  2. Go 分布式学习利器(14)-- Go语言的错误处理
  3. 再记一次ceph object unfound的艰辛历程
  4. 雪花算法 Java 版
  5. caffe prototxt分析
  6. (转)Unity3D - 性能优化之Draw Call
  7. ZooKeeper客户端地址列表的随机原理
  8. 使用ADO.NET 的最佳实践(zz)
  9. php的webservice的wsdl的XML无法显示
  10. wireshark的使用教程--用实践的方式帮助我们理解TCP/IP中的各个协议是如何工作的