——————————DescriptionStart——————————
运行环境 Java≥8、MySQL≥5.7、Tomcat≥8
开发工具 eclipse/idea/myeclipse/sts等均可配置运行
适用 课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的SSM+Maven在线考试系统(java+ssm+bootstrap+jsp+jquery+mysql)
项目介绍
这个项目是一个基于SSM的在线考试系统,分为考试用户和管理员两种角色。
考试用户功能包括: 个人信息中心 成绩查询 在线答题 我的错题本 我的试卷
管理员功能包括: 试题管理 题型管理 用户管理 年级管理 课程管理 试卷管理
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 5.数据库:MySql 5.7版本; 6.是否maven项目:是;
技术栈
后端:Spring+SpringMVC+Mybatis 2. 前端:JSP+css+javascript+jQuery+bootstrap
使用说明
使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中jdbc.properties配置文件中的数据库配置改为自己的配置; 4. 运行项目,在浏览器中输入http://localhost:8080/online_exam_ssm/toLogin.action 登录 学生账户:zhangsan/123456 后管登录地址:http://localhost:8080/online_exam_ssm/admin/login.action 管理员账户:admin/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 51 52 53 UserService userService; @Autowired GradeService gradeService; @RequestMapping("/login.action") public String toLoin (User user, Model model, HttpSession session) { if (session.getAttribute("userName" ) != null ) { return "/admin/index" ; } return "/admin/login" ; } @RequestMapping("/toIndex.action") public String toIndex (Model model, HttpSession session) { return "/admin/index" ; } @ResponseBody @RequestMapping("/userLogin.action") public MsgItem checkUser (User user, Model model, HttpSession session) { if (StringUtils.isEmpty(user.getUserName())) { return MsgItem.error("请填写用户名" ); } if (StringUtils.isEmpty(user.getUserPwd())) { return MsgItem.error("请填写密码" ); } User loginUser = userService.loginCheck(user); if (loginUser == null ) { return MsgItem.error("用户名或密码错误" ); } if (loginUser.getUserType() != 2 ) { return MsgItem.error("用户类型不匹配" ); } session.setAttribute("adminName" , loginUser.getUserName()); session.setAttribute("adminUser" , loginUser); return MsgItem.success("登录成功" ); }
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 } package com.lyy.edu.controller.admin;@RequestMapping("/admin/grade") @Controller public class GradeController { @Autowired GradeService gradeService; @Autowired CourseService courseService; @RequestMapping("/toGradePage.action") public String toGradePage (@RequestParam(value="page", defaultValue="1") int page, Grade grade,Model model, HttpSession session) { PageInfo<Grade> pageInfo = gradeService.findByPage(grade, page, 5 ); List<Grade> dataList = pageInfo.getList(); Course course=null ; for (Grade g : dataList){
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 } if ("8" .equals(question.getTypeId())){ inpList.add(question); } if ("9" .equals(question.getTypeId())){ desList.add(question); } } if (selList.size()>0 ){ Type type = typeService.get(7 ); model.addAttribute("selectQ" , type.getTypeName()+"(" +type.getScore()+"分)" ); model.addAttribute("selList" , selList); } if (inpList.size()>0 ){ Type type = typeService.get(8 ); model.addAttribute("inpQ" , type.getTypeName()+"(" +type.getScore()+"分)" ); model.addAttribute("inpList" , inpList); } if (desList.size()>0 ){ Type type = typeService.get(9 ); model.addAttribute("desQ" , type.getTypeName()+"(" +type.getScore()+"分)" ); model.addAttribute("desList" , desList); } model.addAttribute("paper" , paper); session.setAttribute("active" , "paper" ); return "/user/paperdetail" ; } @SuppressWarnings({ "unchecked", "rawtypes" }) @RequestMapping("/toMyPaperPage.action") public String toMyPaperPage (User user,Model model, HttpSession session) { User loginUser = (User) session.getAttribute("user" ); if (loginUser==null ) {
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 @RequestMapping("/deleteUser.action") public String deleteUser (String userId, Model model) { if (userId != null ) { String ids[] = userId.split("," ); for (int i = 0 ; i < ids.length; i++) { userService.delete(ids[i]); } } return "redirect:/admin/getAllUser.action" ; } @RequestMapping("/passinfo.action") public String passUserInfo (@RequestParam("ids") String ids) { User us = new User(); String currentIds[] = ids.split("," ); for (int i = 0 ; i < currentIds.length; i++) { us.setUserId(Integer.parseInt(currentIds[i])); us.setUserState(1 ); userService.update(us); } return "redirect:/admin/getFindPending.action" ; } @RequestMapping("/failinfo.action") public String failUserInfo (@RequestParam("ids") String ids) { User user = new User(); String currentIds[] = ids.split("," ); for (int i = 0 ; i < currentIds.length; i++) { user.setUserId(Integer.parseInt(currentIds[i])); user.setUserState(1 );
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 MsgItem.error("用户名或密码错误" ); } if (loginCheck.getUserType()!=0 ) { return MsgItem.error("用户类型不匹配" ); } if (loginCheck.getUserState()==0 ) { return MsgItem.error("该账号还未通过审核" ); } session.setAttribute("userName" , loginCheck.getUserName()); session.setAttribute("user" , loginCheck); return MsgItem.success("登录成功 " ); } @RequestMapping("/toRegistPage.action") public String toRegistPage (Model model, HttpSession session) { List<Grade> list = gradeService.find(new Grade()); model.addAttribute("grade" , list); return "/user/regist" ; } @ResponseBody @RequestMapping("/addUserInfo.action") public MsgItem addUserInfo (User user, Model model, HttpSession session) { if (StringUtils.isEmpty(user.getUserName())) { return MsgItem.error("请填写用户名" ); } if (StringUtils.isEmpty(user.getUserPwd())) { return MsgItem.error("请填写密码" ); } if (StringUtils.isEmpty(user.getEmail())) {
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 52 model.addAttribute("message", "<font color ='green' > 验证通过</font > "); } model.addAttribute("userId", userId); return "/admin/info-reg"; } /** * ajax验证用户账号是否存在 * Id * @return */ @RequestMapping("/userRegist.action") @ResponseBody public MsgItem userRegist(String userId, Model model, HttpSession session) { MsgItem msgItem = new MsgItem(); User user = userService.get(userId); if (user != null) { msgItem.setErrorNo("1"); msgItem.setErrorInfo("账号已经存在"); } else { msgItem.setErrorNo("0"); msgItem.setErrorInfo("<font color ='green' > 验证通过</font > "); } return msgItem; } /** * 注销登录 * * @param session * @return */ @RequestMapping("/exitSys.action") public String exitSys(User user, Model model, HttpSession session) { if (session.getAttribute("userName") != null) { session.removeAttribute("userName"); session.removeAttribute("adminUser"); return "forward:/admin/login.action"; } return "/admin/login"; } //跳转到题库录入页面 @RequestMapping(value = "/toQueDep.action", method = RequestMethod.POST) public String toQueDep(Model model, HttpSession session) { return "/admin/info-reg"; }
——————————PayStart——————————
项目链接: https://javayms.github.io?id=421122572008200tx https://javayms.pages.dev?id=421122572008200tx