基于javaweb的在线高中考试系统(java+ssm+jsp+mysql)

基于javaweb的在线高中考试系统(java+ssm+jsp+mysql)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

20220519002322

20220519002324

20220519002325

20220519002326

20220519002327

20220519002328

基于javaweb+jsp的在线高中考试系统(java+SSM+Jsp+Mysql+Maven)

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

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

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

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

登录控制层:

@Controller

public class LoginController {

@Autowired

private StudentService studentService;

@Autowired

private TeacherService teacherService;

@Autowired

private QuestionService questionService;

@Autowired

private PaperService paperService;

@Autowired

private ClasseService classeService;

@Autowired

private 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 ScoreHStu=recordService.queryRankScoreRecord();

List 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 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 {

@Autowired

private ClasseMapper classeMapper;

@Autowired

private StudentService studentService;

//查看所有学生

@RequestMapping(“/getAllStudent”)

public String getAllStudent(Model model){

List 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 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 {

@Autowired

private QuestionService questionService;

@Autowired

private TeacherService teacherService;

@Autowired

private PaperService paperService;

//查看所有试题 pagesize控制每页数据条数

@RequestMapping(“/getAllQuestion”)

public String getAllQuestion(Question question,@RequestParam(defaultValue = “1”) int pageNum,

@RequestParam(defaultValue = “4”) int pageSize,

Model model){

//查找所有题目课程和所有类型,且去重

List questionCourses=questionService.queryAllCourse();

questionCourses.add(new Question(“bug”,“all”));

List 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 questionids=paperService.queryALlQuestionId();

List quesIds=new ArrayList<>();

for(Question qid:questionids){

quesIds.add(qid.getQuestionId());

model.addAttribute(“quesIds”,quesIds);

PageHelper.startPage(pageNum,pageSize);//这行是重点,表示从pageNum页开始,每页pageSize条数据

List questions = questionService.getAll(question);

PageInfo pageInfo = new PageInfo(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 questionCourses=questionService.queryAllCourse();

List 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 questionCourses=questionService.queryAllCourse();

List 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”;



版权声明:本文为m0_68552069原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。