一.登陆模块

前台提交账号和密码传到后台处理控制层

1.1 首先是控制器

@RequestMapping(value="/studentLogin", method=RequestMethod.POST)public ModelAndView studentLogin(StudentInfo student, HttpServletRequest request) {ModelAndView model = new ModelAndView();StudentInfo loginStudent = studentInfoService.getStudentByAccountAndPwd(student.getStudentAccount());if(loginStudent == null || !student.getStudentPwd().equals(loginStudent.getStudentPwd())){model.setViewName("home/suc");return model;}request.getSession().setAttribute("loginStudent", loginStudent);System.out.println(request.getSession().getAttribute("loginStudent"));model.setViewName("home/suc");System.out.println("执行完毕");return model;}
}

1.2 在这里会调用服务层

StudentInfo loginStudent = studentInfoService.getStudentByAccountAndPwd(student.getStudentAccount());

1.3 服务层接口

public StudentInfo getStudentByAccountAndPwd(String studentAccount);

1.4 服务层实现

public StudentInfo getStudentByAccountAndPwd(String studentAccount) {     return studentInfoMapper.getStudentByAccountAndPwd(studentAccount);//调用dao接口}

1.5 数据层接口

public StudentInfo getStudentByAccountAndPwd(String studentAccount);

1.6  数据层实现

<mapper namespace="com.caizhen.weknow.dao.StudentInfoMapper"><!-- 定义resultMap --><resultMap type="com.caizhen.weknow.domain.StudentInfo" id="queryStudent"><!-- 学号 --><id column="studentId" property="studentId"/><!-- 学生姓名 --><result column="studentName" property="studentName"/><!-- 学生账号 --><result column="studentAccount" property="studentAccount"/><!-- 学生账号密码 --><result column="studentPwd" property="studentPwd"/><!-- 班级 --><!-- 班级自身的属性与数据库字段的映射 --> <association property="classInfo" javaType="com.caizhen.weknow.domain.ClassInfo"><id column="classId" property="classId"/><result column="className" property="className"/></association><!-- 年级 --><!-- 年级自身的属性与数据库字段的映射 --> <association property="grade" javaType="com.caizhen.weknow.domain.GradeInfo"><id column="gradeId" property="gradeId"/><result column="gradeName" property="gradeName"/></association></resultMap><select id="getStudentByAccountAndPwd" parameterType="java.lang.String" resultMap="queryStudent">SELECT a.*,b.className,c.gradeId,c.gradeName FROM StudentInfo aINNER JOIN ClassInfo b ON a.classId=b.classIdINNER JOIN GradeInfo c ON b.gradeId=c.gradeIdWHERE studentAccount=#{studentAccount}</select>
</mapper>

 二:考试中心模块

<li><a id="examCenter-link" target="home" style="cursor: pointer;" href="willexams?classId=${sessionScope.loginStudent.classInfo.classId }&gradeId=${sessionScope.loginStudent.grade.gradeId }&studentId=${sessionScope.loginStudent.studentId }" >考试中心</a></li>

向url:willexams传入三个参数:classId,gradeId,studentId

2.1进入控制器

@RequestMapping("/willexams")public ModelAndView getStudentWillExam(@RequestParam("classId") Integer classId,@RequestParam("gradeId") Integer gradeId,@RequestParam(value="studentId", required=false) Integer studentId) {ModelAndView model = new ModelAndView();model.setViewName("/home/examCenter");                //将classId和gradeId存入map集合中Map<String, Object> map = new HashMap<String, Object>();map.put("classId", classId);map.put("gradeId", gradeId);List<ExamPlanInfo> examPlans = examPlanInfoService.getStudentWillExam(map);model.addObject("examPlans", examPlans);model.addObject("gradeId", gradeId);return model;}

2.2 进入服务层接口

public List<ExamPlanInfo> getStudentWillExam(Map<String, Object> map);

2.3进入服务层实现层

public List<ExamPlanInfo> getStudentWillExam(Map<String, Object> map) {return examPlanInfoMapper.getStudentWillExam(map);
}

2.4 进入数据协议层

public List<ExamPlanInfo> getStudentWillExam(Map<String, Object> map);

2.5 进入数据实现层

<mapper namespace="com.caizhen.weknow.dao.ExamPlanInfoMapper"><resultMap type="com.caizhen.weknow.domain.ExamPlanInfo" id="queryWillExam"><id column="examPlanId" property="examPlanId"/><result column="beginTime" property="beginTime"/><!-- 科目 --><association property="course" javaType="com.caizhen.weknow.domain.CourseInfo"><id column="courseId" property="courseId"/><result column="courseName" property="courseName"/></association><!-- 班级 --><association property="clazz" javaType="com.caizhen.weknow.domain.ClassInfo"><id column="classId" property="classId"/></association><!-- 试卷 --><association property="examPaper" javaType="com.caizhen.weknow.domain.ExamPaperInfo"><id column="examPaperId" property="examPaperId"/><result column="examPaperName" property="examPaperName"/><result column="subjectNum" property="subjectNum"/><result column="examPaperScore" property="examPaperScore"/><result column="examPaperEasy" property="examPaperEasy"/><result column="examPaperTime" property="examPaperTime"/></association></resultMap><!-- 查询学生待考信息 --><!-- 考试安排表  examplaninfo a--><!-- 班级信息表 classinfo  b--><!-- 年级表 gradeinfo c --><!-- 试卷表 exampaperinfo d --><!-- 课程表 courseinfo e --><!-- 需要的参数1.a.* 考试安排表所有字段2.d.examPaperName 试卷名称3.d.subjectNum 试题号4.d.examPaperScore 试卷分数5.d.examPaperEasy 试卷难易度6.d.examPaperTime  考试时长5.e.coure.name  课程名称--><select id="getStudentWillExam" parameterType="java.util.Map" resultMap="queryWillExam">SELECT a.*,d.examPaperName,d.subjectNum,d.examPaperScore,d.examPaperEasy,d.examPaperTime,e.courseName FROM ExamPlanInfo aINNER JOIN ClassInfo b ON a.classId=b.classIdINNER JOIN GradeInfo c ON b.gradeId=c.gradeIdINNER JOIN ExamPaperInfo d ON a.examPaperId=d.examPaperIdINNER JOIN CourseInfo e ON a.courseId=e.courseIdWHERE a.classId=#{classId} AND b.gradeId=#{gradeId}</select>
</mapper>

2.6 定向到考试中心界面判断exPlans中的条数是否大于0

<c:when test="${fn:length(examPlans) > 0 }">

如果不是则输出页面

<c:otherwise>
<div class="jumbotron">
<h1>暂无待考信息</h1>
<p>请等待教师分配</p>
</div></c:otherwise>

 三:历史考试模块

1.前台

<!-- 考试历史 -->
<li><a id="mineCenter-link" target="home" style="cursor: pointer;" href="history/${sessionScope.loginStudent.studentId }" studentId="${sessionScope.loginStudent.studentId }">考试历史</a></li>

1.1 前台状态校验

<script type="text/javascript">$(function() {//考试中心状态判断$("#examCenter-link, #mineCenter-link").click(function() {//判断是否登录var studetnId = $(this).attr("studentId");//如果学生号为空if(studetnId.trim() == "" || studetnId == null) {zeroModal.show({title: "提示",content: "登录后才能查看",width : '200px',height : '130px',overlay : false,ok : true,onClosed : function() {location.reload();}});return false;}});

2.后台

2.1 如果学生成功登陆后点击历史考试(控制层)

@Controller
public class ExamHistoryInfoHandler {@Autowiredprivate ExamHistoryPaperService examHistoryPaperService;@RequestMapping("/historys")public ModelAndView examHistorys() {List<ExamHistoryInfo> historys = examHistoryPaperService.getExamHistoryToTeacher();ModelAndView model = new ModelAndView("admin/examHistorys");model.addObject("historys", historys);return model;}
}

2.2 服务层

private ExamHistoryPaperService examHistoryPaperService;

服务层

public interface ExamHistoryPaperService {//查询考试历史信息,针对前台学生查询public List<ExamHistoryPaper> getExamHistoryToStudent(int studentId);public int isAddExamHistory(Map<String, Object> map);public int getHistoryInfoWithIds(Map<String, Object> map);public List<ExamHistoryInfo> getExamHistoryToTeacher();
}

2.3 服务实现层

@Service
public class ExamHistoryPaperServiceImpl implements ExamHistoryPaperService {@Autowiredprivate ExamHistoryPaperMapper examHistoryPaperMapper;public List<ExamHistoryPaper> getExamHistoryToStudent(int studentId) {return examHistoryPaperMapper.getExamHistoryToStudent(studentId);}public int isAddExamHistory(Map<String, Object> map) {return examHistoryPaperMapper.isAddExamHistory(map);}public int getHistoryInfoWithIds(Map<String, Object> map) {return examHistoryPaperMapper.getHistoryInfoWithIds(map);}public List<ExamHistoryInfo> getExamHistoryToTeacher() {return examHistoryPaperMapper.getExamHistoryToTeacher();}
}

2.4 数据接口层

public interface ExamHistoryPaperMapper {//查询考试历史信息,针对前台学生查询public List<ExamHistoryPaper> getExamHistoryToStudent(int studentId);public int isAddExamHistory(Map<String, Object> map);public int getHistoryInfoWithIds(Map<String, Object> map);//查询考试历史信息,针对后台教师查询public List<ExamHistoryInfo> getExamHistoryToTeacher();
}

2.5 数据实现层

<mapper namespace="com.caizhen.weknow.dao.ExamHistoryPaperMapper"><resultMap type="com.caizhen.weknow.domain.ExamHistoryInfo" id="queryExamHistoryToStudentResultMap"><id column="historyId" property="historyId"/><result column="examScore" property="examScore"/><association property="examPaper" javaType="com.caizhen.weknow.domain.ExamPaperInfo"><id column="examPaperId" property="examPaperId"/><result column="examPaperName" property="examPaperName"/><result column="examPaperScore" property="examPaperScore"/><result column="subjectNum" property="subjectNum"/></association></resultMap><!-- 查询考试历史信息,针对前台学生查询 --><select id="getExamHistoryToStudent" parameterType="int" resultType="ExamHistoryPaper">SELECTa.historyId,a.examScore,b.examPaperId,b.examPaperName,b.examPaperScore,b.subjectNum,c.beginTimeFROM ExamHistoryInfo aLEFT JOIN examPaperInfo b ON a.examPaperId=b.exampaperIdLEFT JOIN examPlanInfo c ON b.examPaperId=c.examPaperIdWHERE studentId=#{studentId}</select><!-- 新增历史记录 --><insert id="isAddExamHistory" parameterType="java.util.Map">INSERT INTO ExamHistoryInfo VALUES(NULL, #{studentId}, #{examPaperId}, #{examScore});</insert><select id="getHistoryInfoWithIds" parameterType="java.util.Map" resultType="int">SELECT COUNT(*) FROM ExamHistoryInfo WHERE studentId=#{studentId} AND examPaperId=#{examPaperId}</select><resultMap type="com.caizhen.weknow.domain.ExamHistoryInfo" id="queryExamHistoryToTeacherResultMap"><id column="historyId" property="historyId"/><result column="examScore" property="examScore"/><association property="examPaper" javaType="com.caizhen.weknow.domain.ExamPaperInfo"><id column="examPaperId" property="examPaperId"/><result column="examPaperName" property="examPaperName"/><result column="examPaperScore" property="examPaperScore"/><result column="subjectNum" property="subjectNum"/></association><association property="student" javaType="com.caizhen.weknow.domain.StudentInfo"><id column="studentId" property="studentId"/><result column="studentName" property="studentName"/></association></resultMap><!-- 查询考试历史信息,针对后台教师查询 --><select id="getExamHistoryToTeacher" resultMap="queryExamHistoryToTeacherResultMap">SELECTa.historyId,a.examScore,b.examPaperId,b.examPaperName,b.examPaperScore,b.subjectNum,d.studentId,d.studentNameFROM ExamHistoryInfo aINNER JOIN examPaperInfo b ON a.examPaperId=b.exampaperIdLEFT JOIN StudentInfo d ON a.studentId=d.studentId;</select>
</mapper>

转载于:https://www.cnblogs.com/cainame/p/10346613.html

ssm+mysql+jsp打造在线考试系统WeKnow-学生端相关推荐

  1. 基于ssm+mysql+jsp作业管理(在线学习)系统

    基于ssm+mysql+jsp作业管理(在线学习)系统 一.系统介绍 二.功能展示 1.用户登陆 2.用户注册 3.在线学习(评论)--学生 4.任务列表--学生 5.我的作业--学生 6.个人中心 ...

  2. 手把手教你做一个jsp+ssm+mysql实现的在线考试系统之在线考试系统源码+视频开发教程+参考论文+开题报告

    今天给大家演示的是一款由jsp+ssm框架(spring+springMVC+mybatis)+mysql实现的在线考试系统源码和开发教程,本系统配有完整的源码.45讲视频开发教程.数据库文件.项目素 ...

  3. 在线考试新入.html,JSP+SSM+MySql实现的在线考试系统毕设指导思路模板

    <p style="font-family:" font-size:16px;text-indent:2em;color:#666666;background-color:# ...

  4. Java JSP JAVAweb在线考试系统源码网上考试系统源码(ssm考试管理系统)

    Java JSP JAVAweb在线考试系统源码网上考试系统源码(ssm考试管理系统) 常见的Javaweb题材有 理财系统,就业管理系统,汽车租赁,简易网盘,疫情数据查看,在线招标房,屋租赁,教务管 ...

  5. JSP JAVAweb在线考试系统源码网上考试系统源码(ssm考试管理系统)

    JSP JAVAweb在线考试系统源码网上考试系统源码(ssm考试管理系统)

  6. 基于SSM整合的驾照在线考试系统

    基于SSM整合的驾照在线考试系统 项目描述 主要功能有: 1.用户功能模块 用户注册登 用户可以通过用户名邮箱注册网站,并且通过注册的用户登陆网站. 2.随机练习 从题库中随机取出指定数量的题目供学员 ...

  7. 基于HTML在线考试系统开题报告,基于JSP的在线考试系统 开题报告.doc

    基于JSP的在线考试系统 开题报告 毕业设计(论文)开题报告 论文题目: 基于JSP的在线考试系统 Online Examination System Based on JSP on JSP 学 生 ...

  8. 基于Java与MySQL开发的在线考试系统

    1 概述 1.1 简介 在Exam++考试系统第一版的基础上,我们对ExamStack V2.0进行了大量代码重构,同时也对数据模型做了部分调整.为了减小学员考试交卷时大量并发带来的系统风险,我们尝试 ...

  9. 在线考试系统_管理员端

    专题习作_在线考试系统_管理员端 作者:力争上游_韩元欣 登录页面 登录页面包括校验管理号与密码以及页面记住密码功能. 校验账号与密码 用户输入正确的账号和密码即可以登录. 用户输入账号和密码并点击登 ...

最新文章

  1. CPU 及 IO 平均开销较大脚本
  2. python进程间通信 listener_python进程间通信之Queue
  3. pythonopencv算法_python opencv之分水岭算法示例
  4. cgo linux arm,Golang交叉编译各个平台的二进制文件
  5. 2019牛客第八场A All-one Matrices(单调栈)
  6. gridview DataFormatString
  7. 2017 ICPC沈阳区域赛
  8. java魔兽猎人_Java基于Swing实现的打猎射击游戏代码
  9. 在windows下codeblocks中配置pthread库
  10. matlab人民币识别,Matlab图像处理学习笔记(六):基于sift特征点的人民币识别...
  11. tensorflow英语怎么读_英语不行?你可以试试TensorFlow官方中文版教程
  12. 记单表数据较多的数据库查询实例及测试结果
  13. gis环境设置在哪_GIS局部放电在线监测系统
  14. Linux常用命令大全(非常全面)
  15. 使用阿里云邮件推送服务发送验证码
  16. 音频开发_Microphone Array Beamforming_Delay Sum Beamforming
  17. Linux版主机卫士安装使用
  18. LeCo-81.搜索旋转数组(二)
  19. 悉尼大学理学院计算机科学,澳洲悉尼大学理学院中国留学生
  20. 什么是数字化?企业如何实现数字化?

热门文章

  1. escape()、encodeURI()、encodeURIComponent()区别详解
  2. .NET 11 个 Visual Studio 代码性能分析工具
  3. [转]php socket编程通信
  4. linux查看CPU信息
  5. Thinkphp 源码分析
  6. slice_input_producer在2.0版本里怎么用_用Gan生成一维数据(附代码)
  7. 833 计算机学科专业基础综合,2017年西安电子科技大学计算机学院833计算机学科专业基础综合考研仿真模拟题...
  8. verilog hdl数字集成电路设计原理与应用_数字IC设计经典书籍推荐
  9. word饼图如何画引导线_网络授课如何手写、标注?
  10. java知识理论_JAVA理论知识 - OSC_rnoszD的个人空间 - OSCHINA - 中文开源技术交流社区...