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





基于javaweb的SpringBoot在线考试平台(java+springboot+ssm+mysql+maven+thymeleaf+html+redis)
一、项目简述
功能列表 考试前台 /系统登录:学生、教师、管理员登录 /门户首页:无需认证访问 /在线考试:需认证即可查看当前考除目 /题库中心:需认证查看题库 /成绩查询:需认证查询成绩 /留言板:需认证留言 管理后台 /考:署理:发布考试,考试列表,课程管理,题库管 理,成绩管理,成绩情况 /权限管理:学院管理,班级管理,用户管理,角色管 理,资源管理 4网站管理:基础信息,友链管理,评论管理,标签管理 /系统管理:在线用户 /上传管理:云存储配置 /运维管理:数据监控
二、项目运行
环境配置: Jdk1.8 + mysql + Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts 都支持)
项目技术: JSP +SpringBoot + MyBatis + Redis+ Thymeleaf+ Druid+ JQuery + SLF4J+ Fileupload + maven等等
——————————CodeStart——————————
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
@Controller @RequestMapping("grade") public class GradeController { @Autowired private GradeService gradeService; @Autowired private ExaminationService examService; @Autowired private UserService userService; @PostMapping("list") @ResponseBody public PageResultVo loadGrade(GradeConditionVo gradeConditionVo, Integer limit, Integer offset) { PageHelper.startPage(PageUtil.getPageNo(limit, offset),limit); User user = (User)SecurityUtils.getSubject().getPrincipal(); List<String> roleList = userService.selectRoleByUserId(user.getUserId()); if(!roleList.contains("超级管理员")) { if(roleList.contains("老师")) { gradeConditionVo.setAuthor(user.getNickname());
|
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
| public void setKickoutAfter(boolean kickoutAfter) { this.kickoutAfter = kickoutAfter; }
public void setMaxSession(int maxSession) { this.maxSession = maxSession; }
public void setSessionManager(SessionManager sessionManager) { this.sessionManager = sessionManager; }
public void setCacheManager(CacheManager cacheManager) { this.cache = cacheManager.getCache("shiro_redis_cache"); }
@Override protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) throws Exception { return false; }
@Override protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws Exception { Subject subject = getSubject(request, response); if(!subject.isAuthenticated() && !subject.isRemembered()) { return true; }
Session session = subject.getSession(); User user = (User) subject.getPrincipal(); String username = user.getUsername(); Serializable sessionId = session.getId();
Deque<Serializable> deque = cache.get(username); if(deque==null){ deque = new LinkedList<Serializable>(); } if(!deque.contains(sessionId) && session.getAttribute("kickout") == null) { deque.push(sessionId);
|
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
| @Controller public class ExamWebController { @Autowired private ExaminationService examService; @Autowired private GradeService gradeService; @Autowired private QuestionService questionService; @Autowired private SubjectService subjectService; @Autowired private CommentService commentService; @Autowired private LoveService loveService; @Autowired private UserService userService; @Autowired private ClassesService classesService; @Autowired private ShiroRealm shiroRealm;
|
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
| public ResponseVo add(User userForm, String confirmPassword, Integer passwordType){ String username = userForm.getUsername(); User user = userService.selectByUsername(username); if (null != user) { return ResultUtil.error("该学号已存在"); } if(passwordType == 0) { String password = userForm.getPassword(); if (confirmPassword != null && password != null) { if (!confirmPassword.equals(password)) { return ResultUtil.error("两次密码不一致"); } } }else { userForm.setPassword(CoreConst.DEFAULT_PASSWORD); } userForm.setUserId(UUIDUtil.getUniqueIdByUUId()); userForm.setImg(CoreConst.DEFAULT_IMG); userForm.setStatus(CoreConst.STATUS_VALID); Date date = new Date(); userForm.setCreateTime(date); userForm.setUpdateTime(date); userForm.setLastLoginTime(date); PasswordHelper.encryptPassword(userForm); int num = userService.register(userForm); if(num > 0){ return ResultUtil.success("添加用户成功"); }else { return ResultUtil.error("添加用户失败"); } }
@GetMapping("/edit") public String userDetail(Model model, String userId){ User user = userService.selectByUserId(userId); List<Classes> classes = classesService.selectAll(); List<String> grades = userService.selectGradeList(); model.addAttribute("user", user);
|
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
| subject.logout(); } catch (Exception e) { } saveRequest(request); Map<String, String> resultMap = new HashMap<String, String>(); if ("XMLHttpRequest".equalsIgnoreCase(((HttpServletRequest) request).getHeader("X-Requested-With"))) { resultMap.put("user_status", "300"); resultMap.put("message", "您已经在其他地方登录,请重新登录!"); out(response, resultMap); }else{ WebUtils.issueRedirect(request, response, kickoutUrl); } return false; } return true; } private void out(ServletResponse hresponse, Map<String, String> resultMap) throws IOException { try { hresponse.setCharacterEncoding("UTF-8"); PrintWriter out = hresponse.getWriter(); out.println(JSON.toJSONString(resultMap)); out.flush(); out.close(); } catch (Exception e) { System.err.println("KickoutSessionFilter.class 输出JSON异常,可以忽略。"); } } } package com.exam.controller;
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| out.flush(); out.close(); } catch (Exception e) { System.err.println("KickoutSessionFilter.class 输出JSON异常,可以忽略。"); } } } package com.exam.controller;
@Controller @RequestMapping("exam") public class ExaminationController { @Autowired private ExaminationService examService;
|
——————————PayStart——————————
项目链接:
https://javayms.github.io?id=071422282105200ci
https://javayms.pages.dev?id=071422282105200ci