资源简介
网络在线考试架构源码,本例使用sturts与javabean开发
代码片段和文件信息
package com.wgh.action;
import java.util.List;
import javax.servlet.http.*;
import org.apache.struts.action.*;
import com.wgh.actionForm.LessonForm;
import com.wgh.dao.LessonDAO;
public class Lesson extends Action {
private LessonDAO lessonDAO = null;
public Lesson() {
this.lessonDAO = new LessonDAO();
}
public ActionForward execute(ActionMapping mapping ActionForm form
HttpServletRequest request HttpServletResponse response) {
String action = request.getParameter(“action“);
System.out.println(“获取的查询字符串:“ + action);
if (action == null || ““.equals(action)) {
return mapping.findForward(“error“);
} else if (“lessonQuery“.equals(action)) {
return lessonQuery(mapping form request response);
} else if (“lessonAdd“.equals(action)) {
return lessonAdd(mapping form request response);
} else if (“lessonDel“.equals(action)) {
return lessonDel(mapping form request response);
}else if(“selectLesson“.equals(action)){
return selectLesson(mapping form request response);
}else if(“ready“.equals(action)){
return ready(mapping form request response);
}
request.setAttribute(“error“ “操作失败!“);
return mapping.findForward(“error“);
}
// 查询课程信息
private ActionForward lessonQuery(ActionMapping mapping ActionForm form
HttpServletRequest request HttpServletResponse response) {
request.setAttribute(“lessonQuery“ lessonDAO.query(0));
return mapping.findForward(“lessonQuery“);
}
// 添加课程
private ActionForward lessonAdd(ActionMapping mapping ActionForm form
HttpServletRequest request HttpServletResponse response) {
LessonForm lessonForm = (LessonForm) form;
int ret = lessonDAO.insert(lessonForm);
System.out.println(“返回值ret:“ + ret);
if (ret == 1) {
return mapping.findForward(“lessonAdd“);
} else if (ret == 2) {
request.setAttribute(“error“ “该课程已经添加!“);
return mapping.findForward(“error“);
} else {
request.setAttribute(“error“ “添加课程失败!“);
return mapping.findForward(“error“);
}
}
// 删除课程
private ActionForward lessonDel(ActionMapping mapping ActionForm form
HttpServletRequest request HttpServletResponse response) {
LessonForm lessonForm = (LessonForm) form;
int ret = lessonDAO.delete(lessonForm);
if (ret == 0) {
request.setAttribute(“error“ “删除课程失败!“);
return mapping.findForward(“error“);
} else {
return mapping.findForward(“lessonDel“);
}
}
//在线考试时选择课程
private ActionForward selectLesson(ActionMapping mapping ActionForm form
HttpServletRequest request HttpServletResponse response) {
HttpSession session = request.getSession();
String stu=session.getAttribute(“student“).toString(); //获取准考证号
List list=lessonDAO.query(stu); //查询包括考试题目的课程列表,但不包括已经考过的科目
if(list.size()<1){
return mapping.findForward(“noenLesson“);
}else{
request.setAttribute(“lessonList“list);
return mapping.findForward(“selectLesson“);
}
}
//准备考试
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 793 2007-12-17 20:50 08\copyright.jsp
文件 1979 2007-12-20 14:14 08\CSS\st
文件 1048576 2008-01-11 13:22 08\Databa
文件 1048576 2008-01-11 13:22 08\Databa
文件 488 2007-12-21 16:57 08\dealNull.jsp
文件 1257 2007-12-08 16:09 08\default.jsp
文件 868 2007-12-07 19:49 08\error.jsp
文件 2538 2007-12-21 17:05 08\examRule.jsp
文件 587 2007-12-05 01:10 08\Images\add.gif
文件 49 2007-12-17 15:24 08\Images\bg_01.gif
文件 115145 2007-12-08 08:38 08\Images\default_bottom.JPG
文件 227556 2007-12-08 10:54 08\Images\default_mid.JPG
文件 105753 2007-12-08 08:38 08\Images\default_top.jpg
文件 19902 2007-12-08 03:48 08\Images\error.jpg
文件 173 2007-12-08 10:43 08\Images\f_ico.gif
文件 78893 2007-12-07 20:12 08\Images\login_bottom.jpg
文件 52384 2007-12-07 20:14 08\Images\login_mid.jpg
文件 102349 2007-12-24 14:03 08\Images\login_top.jpg
文件 65 2007-12-17 20:05 08\Images\m_ico.gif
文件 59 2007-12-17 20:37 08\Images\m_ico1.gif
文件 76626 2007-12-08 03:48 08\Images\m_login.jpg
文件 89527 2007-12-18 08:59 08\Images\m_top.jpg
文件 3069 2007-12-08 22:47 08\Images\seedPwd.gif
文件 13360 2007-12-20 13:01 08\Images\startExam_bottom.jpg
文件 18469 2007-12-20 13:02 08\Images\startExam_ico.jpg
文件 13318 2007-12-20 13:01 08\Images\startExam_left.jpg
文件 14295 2007-12-20 12:59 08\Images\startExam_leftBottom.jpg
文件 14310 2007-12-20 12:57 08\Images\startExam_leftTop.jpg
文件 13322 2007-12-20 13:01 08\Images\startExam_right.jpg
文件 14395 2007-12-20 13:00 08\Images\startExam_rightBottom.jpg
............此处省略148个文件信息
评论
共有 条评论