loginaction.java

来自「在线考试 考生登陆 查分 管理员管理后台等的 的的的的达到的达到的的的」· Java 代码 · 共 85 行

JAVA
85
字号
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package com.eonline.controller;import org.apache.struts.action.ActionForm;import org.apache.struts.action.ActionMapping;import org.apache.struts.action.ActionForward;import org.apache.struts.action.ActionErrors;import org.apache.struts.action.ActionMessage;import org.apache.struts.action.ActionMessages;import javax.servlet.*;import javax.servlet.http.*;import java.util.*;import com.eonline.model.*;import com.eonline.view.LoginForm;import demo.ExamSessionRemote;import demo.LoginSessionRemote;import demo.ScoreSessionRemote;import javax.naming.InitialContext;/** * * @author Administrator */public class LoginAction extends org.apache.struts.action.Action {    /**     * 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 {        ServletContext context = getServlet().getServletContext();        ActionErrors errors = new ActionErrors();        saveMessages(request, errors);        try {            LoginForm myForm = (LoginForm) form;            InitialContext ctx = new InitialContext();           LoginSessionRemote loginSvc = (LoginSessionRemote)ctx.lookup(LoginSessionRemote.class.getName());           loginSvc.LoginSessionBean(myForm.getUsername(), myForm.getPassword()) ;            Euser userItem = loginSvc.getUserInfo();            HttpSession session = request.getSession();            session.setAttribute("userItem", userItem); //把用户信息存入session作用域            List<Item1> testList = new LinkedList();                      ExamSessionRemote eSvc = (ExamSessionRemote)ctx.lookup(ExamSessionRemote.class.getName());            //ExamService eSvc = new ExamService();            testList = eSvc.getItemList();            ScoreSessionRemote scoreservice = (ScoreSessionRemote)ctx.lookup(ScoreSessionRemote.class.getName());           scoreservice.ScoreSessionBean(userItem.getUid()) ;            List scoreList = scoreservice.getScoreList();            session.setAttribute("testList", testList); //把题目信息存入session作用域            session.setAttribute("scoreList", scoreList);            return mapping.findForward("success");        } catch (RuntimeException e) {            context.log("An unexpected error: ", e);            errors.add(ActionMessages.GLOBAL_MESSAGE,                    new ActionMessage("error.unexpectedError",                    e.getMessage()));            return mapping.findForward("error");        }    }}

⌨️ 快捷键说明

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