questionaction.java

来自「java网上考试系统」· Java 代码 · 共 88 行

JAVA
88
字号
package com.qrsx.exam.struts.action;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.qrsx.exam.dao.DAOFactory;
import com.qrsx.exam.dao.TestPaperDAO;
import com.qrsx.exam.model.TestPaper;
import com.qrsx.exam.struts.BaseAction;

/**
 * The Action about test Question
 * 
 * @struts.action name="questionForm" path="/exam/question" scope="request"
 *                input="/exam/question_list.jsp" validate="false" parameter="p"
 * 
 * @struts.action-forward name="list" path="/exam/question_list.jsp"
 * 
 * @struts.action-forward name="exam" path="/exam/question_exam.jsp"
 * 
 * @author galaxy
 * 
 */
public class QuestionAction extends BaseAction {

    /**
     * 进入试题列表页面
     */
    public ActionForward list(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws IOException, ServletException {
        String paperid = request.getParameter("paperid");
        return list(paperid, mapping, request);
    }

    /**
     * 获得试题列表信息
     */
    public ActionForward list(String paperid, ActionMapping mapping,
            HttpServletRequest request) {
        // 取得试卷对象的信息
        TestPaperDAO dao = DAOFactory.getDao(TestPaperDAO.class);
        TestPaper paper = dao.findById(paperid, false);

        // 设置返回到页面的信息
        request.setAttribute("paper", paper);
        request.setAttribute("selectquestions", paper.getSelectquestions());
        request.setAttribute("yesnoquestions", paper.getYesnoquestions());

        return mapping.findForward("list");
    }

    /**
     * 进入试题发布页面
     */
    public ActionForward addin(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws IOException, ServletException {
        // 取得试卷对象的信息
        String paperid = request.getParameter("paperid");
        TestPaperDAO paperdao = DAOFactory.getDao(TestPaperDAO.class);
        TestPaper paper = paperdao.findById(paperid, false);
        request.setAttribute("paper", paper);

        // 进入试卷发布页面
        return mapping.findForward("add");
    }

    /**
     * 进入试卷页面的Action方法
     */
    public ActionForward exam(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws IOException, ServletException {
        String paperid = request.getParameter("paperid");
        list(paperid, mapping, request);

        return mapping.findForward("exam");
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?