毕设项目分享 基于SpringMVC的计算机专业认证在线考试系统


0 项目说明

基于SpringMVC的计算机专业认证在线考试系统

提示:适合用于课程设计或毕业设计,工作量达标,源码开放


1 功能模块图

在这里插入图片描述

2 技术选型

1、前端

  • Html/Css/JavaScript
  • Bootstrap
  • jQuery
  • UploadFive

2、后端

  • Spring/SpringMVC/Hibernate
  • Spring Security
  • slf4j/log4j
  • Gson
  • POI
  • Druid

3、数据库

  • MySQL

3 ER图

在这里插入图片描述

4 界面展示

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

5 项目包结构

在这里插入图片描述
在这里插入图片描述

6 项目源码

package pers.corvey.exam.controller;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;

import pers.corvey.exam.controller.common.BaseControllerImpl;
import pers.corvey.exam.entity.Resource;
import pers.corvey.exam.entity.ui.CallBackMessage;
import pers.corvey.exam.exception.FileNotPermitException;
import pers.corvey.exam.service.BuyLogService;
import pers.corvey.exam.service.ResourceService;
import pers.corvey.exam.util.CurrentUtils;
import pers.corvey.exam.util.MyFileUtils;

@Controller
@RequestMapping("/resource")
public class ResourceController extends BaseControllerImpl<Resource, Long> {
	
	private final ResourceService service;
	private final BuyLogService buyLogService;
	
	@Autowired
	public ResourceController(ResourceService service, BuyLogService buyLogService) {
		super(service, "resource-input.jsp", "resource-list.jsp");
		this.service = service;
		this.buyLogService = buyLogService;
		needEntityURLSuffix.add("/download");
	}
	
	@PostMapping("/upload")
	public String upload(Model model, @ModelAttribute("entity") Resource entity,
			@RequestParam("file") MultipartFile multipartFile) {
		save(model, entity, multipartFile);
		return redirect("/all");
	}
	
	@PostMapping(SAVE_PATH)
	public String save(Model model, @ModelAttribute("entity") Resource entity,
			@RequestParam("file") MultipartFile multipartFile) {
		CallBackMessage msg;
		if (multipartFile.getSize() <= 0) {
			msg = CallBackMessage.createDangerMsg("必须上传文件!");
		} else {
			try {
				File file = MyFileUtils.saveFile(multipartFile);
				entity.setFileName(multipartFile.getOriginalFilename());
				entity.setFileSize(multipartFile.getSize());
				entity.setFilePath(file.getPath());
				return baseSave(entity);
			} catch (IOException e) {
				e.printStackTrace();
				msg = CallBackMessage.createDangerMsg("上传文件失败,服务器发生未知异常!");
			} catch (FileNotPermitException e) {
				msg = CallBackMessage.createDangerMsg(e.getMessage());
			}
		}
		CurrentUtils.addAttributeToSession(CallBackMessage.MESSAGE_ATTRIBUTE_NAME, msg);
		return redirect(LIST_PATH);
	}

	@RequestMapping("/download")
	public ResponseEntity<byte[]> download(@ModelAttribute("entity") Resource entity) {
		if (entity == null || entity.getId() == null) {
			return null;
		}
		// 购买失败
		if (!buyLogService.buy(entity)) {
			return null;	// XXX 无法下载时返回的页面不够友好
		}
		try {
			File file = new File(entity.getFilePath());
			InputStream is = new FileInputStream(file);
			byte[] body = new byte[is.available()];
			is.read(body);
			HttpHeaders headers = new HttpHeaders();
			headers.add("Content-Disposition", "attchement;filename=" + file.getName());
			HttpStatus statusCode = HttpStatus.OK;
			ResponseEntity<byte[]> ret = new ResponseEntity<byte[]>(body, headers, statusCode);
			is.close();
			return ret;
		} catch (FileNotFoundException e) {
			CallBackMessage msg = CallBackMessage.createDangerMsg("服务器发生异常,请重试!");
			msg.addToCurrentSession();
			e.printStackTrace();
		} catch (IOException e) {
			CallBackMessage msg = CallBackMessage.createDangerMsg("服务器发生异常,请重试!");
			msg.addToCurrentSession();
			e.printStackTrace();
		}
		return null;	// XXX 无法下载时返回的页面不够友好
	}
	
	@RequestMapping("/all")
	public String all(Model model) {
		List<Resource> resources = service.findAll();
		model.addAttribute("entities", resources);
		return "resource-all";
	}
	
	@RequestMapping("/adminSearch")
	public String adminSearch(Model model, @RequestParam("keyword") String keyword) {
		return baseShowListView(model, service.search(keyword));
	}
	
	@RequestMapping("/search")
	public String search(Model model, @RequestParam("keyword") String keyword) {
		Iterable<Resource> resources = service.search(keyword);
		model.addAttribute("entities", resources);
		return "resource-all";
	}
	
	@RequestMapping("/{resourceId}")
	public String show(Model model, @PathVariable Long resourceId) {
		Resource resource = service.findByID(resourceId);
		model.addAttribute("resource", resource);
		
		boolean hadBought = buyLogService.hadBought(resource);
		model.addAttribute("hadBought", hadBought);
		System.out.println(hadBought);
		return "resource-show";
	}
}

7 最后

项目分享 :
https://gitee.com/asoonis/htw

  • 10
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在线考试系统是一种环保的考试形式,所有的步骤都在电脑上完成。通过对国内高校对题库、考试、练习、考试数据分析、档案管理等的需求,从基本信息、试题建设、题库规划、移动练习、智能组卷、自定义输出、智能排考、数据分析等进行了全流程设计。用户可通过流程定义将现有的管理流程移植到考试系统中,也可自定义管理流程,从而解决学校教考分离的难点和痛点。 现在流行的考试系统都是基于云架构设计,引入了大量的国际先进的信息处理技术,并结合移动互联,支持目前流行的大部分音视频和图片格式,同时可对数学公式、化学公式直接进行处理,可实现传统考试到无纸化考试的完整切换。 在线考试系统可实现智能组卷、智能排考、智能阅卷等功能,用户可实时进行不同程度的干预和调整,从而使整个过程更符合用户要求。一线老师只负责按照考纲教学和试题库建设,考试管理人员负责组织试题建设和从试题库中抽取试卷考试,考试评价由系统根据一定的评价模型自动生成,从而实现了分散建设、集中管理和统一应用的目标。考场抽题组卷智能化、主客观题作答无纸化、主观题教师阅卷网络化、考试质量分析自动化,大大降低了考试过程的人为干预程度,保证了考试效果和教学评价的客观性和公正性。 任课老师可随时安排开放练习和阶段性测试,并通过后台随时查看学生练习情况和知识掌握情况,据此实时调整教学安排,从而使教学更有针对性。学生可通过移动终端随时进行课程练习和自测,从而即时进行知识巩固并且随时掌握自己对知识的掌握程度。
程序实例使用的是读者朋友们比较关注的三层架构所编写,应用的开发环境是VS2008自带的AJAX无刷新环境,并且对于网站安全通过无解密MD5单向加密技术来实现。 读者朋友们在运行本实例时可以先以超级管理员的身份(用户名:mr 密码:mrsoft)来登录,然后可以设置考生ID号和教师ID号,之后便可以以考生或教师身份来登录,这里管理员有权限设置功能。 三层架构小知识: 下面对这几层进行介绍。 1、表示层,它负责响应用户的请求,对于这一层一般代码量很少。大量的处理工作交给其他的层完成。 2、业务逻辑层,用来对数据进行有效性验证,牵涉到对敏感数据的操作都需要经过业务逻辑层做判断,然后才能决定操作是否合法。 3、数据层,封装对数据库的操作。可以做一个通用的数据访问层,以后开发项目时,可以直接拿过来用,并且可以提高工作效率。另外,进行参数传值时,数据都用自定义实体类代替,这样可以实现数据访问层对其它层的完全透明。自定义实体类封装了所有与数据库表结构相关的代码。 4、Common层,用来封装一些常用的功能性代码,主要用来为其它层服务的。还有存放一些自定义实体类型和自定义实体类型集合。用于各层次之间数据交互的承载体。 说明:本书为了适合不同用户群的使用并不是所有程序实例都采用三层架构来设计,网站开发的三层架构并不适合于所有网站开发,应根据实际项目开发情况而定,如果读者朋友们喜欢三层架构模式可以根据本实例的编写将本书中其他未用三层架构的实例也改成三层架构模式。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值