一、ifIsCurrentExam2(path, paperConfigs)
(1)疑惑:对于获取xml路径这一块不是看得很懂。
1 path = path.replaceFirst("%20", " ");
2 path = path.replaceAll("%20", " ");
3 path += cn.cust.exam.util.ConstData.globalDataPath;
4 // 开始
5 String pathsys = this.getClass().getResource("/").toString();
6 String a[] = null;
7 a = pathsys.split("file:/");
8 a = a[1].split("/WEB-INF/classes/");
9 path = a[0];
10 path.replaceAll("/", "//");
11 path += cn.cust.exam.util.ConstData.globalDataPath;
12 path = path.replaceFirst("%20", " ");
13 path = path.replaceAll("%20", " ");
(2)定义flag=false,判断:当changci的个数等于paperConfig的个数时,返回true,即生成的母卷已添加时间;否则返回false。
二、setPaperProperty2(ActionMapping mapping,ActionForm form,
HttpServletRequest request,HttpServletResponse response)
1.ActionForward
ActionForward的作用:封装转发路径,完成页面的跳转和转向。有两种转向,即重定向和请求转发。默认的情况下,actionForward采用的是转发的方式进行页面跳转的。
以下是它的主要参数:
(1)Name属性:指定ActionForward名称,在其他类中也可以通过这个名字调用ActionForward。
(2)Path属性:指明了ActionForward对应的URI。
(3)redirect属性:属性设置为true时被设置为重定向,默认false。
2.ActionMapping
ActionMapping的功能:管理Action的信息和管理Action执行完成以后的ActionForward的信息。它将特定请求映射到特定Action的相关信息存储ActionMapping中,ActionServelt将ActionMapping传送到Action类execute()方法,Action将使用ActionMapping的findForward()方法,此方法返回一个指定名称的ActionForward,这样Action就完成了本地转发。若没有找到具体的ActionForward,就返回一个null.
3.ActionForm
ActionForm用于封装用户的请求参数,而请求参数是通过JSP页面的表单域传递过来的。
4.getStudentExamNum(String changCi, String courseId)
1 int num = -1; //定义num
2 ResultSet rs = null;
3 Connection conn = Connect.getConnection(); //连接数据库
4 String sql = "select count(*) from studentExam where exam_id=? and course_id=? "; //定制sql语句
5 PreparedStatement ps = Connect.prepare(conn, sql); //创建一个PrepareStatement对象
6
7 ps.setInt(1, Integer.parseInt(changCi.trim())); //设置参数
8 ps.setInt(2, Integer.parseInt(courseId.trim()));
9 rs = ps.executeQuery(); //执行查询语句
10 rs.next();
11 num = rs.getInt(1); //把结果集中第一列的值赋给num
12 return num;
13 ---关闭连接---