⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 examaction.java

📁 只做是单选题!数据库表有三张:EUser,EItem,Score
💻 JAVA
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package com.exam.controller;import com.exam.model.ExamService;import com.exam.model.ItemDAO;import com.exam.model.Score;import com.exam.model.ScoreService;import java.util.ArrayList;import java.util.Date;import java.util.List;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import javax.servlet.http.HttpSession;import org.apache.struts.action.ActionForm;import org.apache.struts.action.ActionMapping;import org.apache.struts.action.ActionForward;/** * * @author Administrator */public class ExamAction extends org.apache.struts.action.Action {////    private String a;//    private String answer;    /* forward name="success" path="" */    /**     * This is the action called from the Struts framework.     * @param mapping The ActionMapping used to select this instance.     * @param form The optional ActionForm bean for this request.     * @param request The HTTP Request we are processing.     * @param response The HTTP Response we are processing.     * @throws java.lang.Exception     * @return     */    public ActionForward execute(ActionMapping mapping, ActionForm form,            HttpServletRequest request, HttpServletResponse response)            throws Exception {        HttpSession session = request.getSession();        List answer = new ArrayList();        List sanswer = new ArrayList();        ItemDAO dao = new ItemDAO();        int UID = (Integer) session.getAttribute("uid");        List question_list = (List) session.getAttribute("question_list");        for (int i = 1; i <= question_list.size(); i++) {            String show_values = request.getParameter(new Integer(i).toString());            answer.add(show_values);            sanswer.add(dao.getAnswer(i));            session.setAttribute("answer", answer);        }        ScoreService scoreSvc = new ScoreService();        Score score = scoreSvc.contractors(answer, sanswer, UID);        session.setAttribute("score", score);        scoreSvc.AddScore(score);        return mapping.findForward("success");    }}

⌨️ 快捷键说明

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