adminaction.java

来自「第1章 大学生就业求职网 第2章 网上物流平台 第3章 华奥汽车销售集团网 」· Java 代码 · 共 34 行

JAVA
34
字号
package com.cargo.crotrol;import org.apache.struts.action.*;import javax.servlet.http.*;import com.cargo.model.Admin;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2004</p> * <p>Company: MR</p> * @author BWM * @version 1.0 */public class AdminAction extends Action {    public ActionForward perform(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) {        /**@todo: complete the business logic here, this is just a skeleton.*/        ActionErrors errors=new ActionErrors();        AdminForm adminForm = (AdminForm) actionForm;        Admin admin= adminForm.getAdmin();        String id=this.getServlet().getServletConfig().getInitParameter("id");        String password=this.getServlet().getServletConfig().getInitParameter("password");        if(!admin.getId().equals(id.trim())||!admin.getPassword().equals(password.trim())){            errors.add(ActionErrors.GLOBAL_ERROR,new ActionError("error.logon.fail"));            saveErrors(httpServletRequest,errors);        }        if(!errors.empty()){            return (new ActionForward(actionMapping.getInput()));        }        HttpSession session=httpServletRequest.getSession();        session.setAttribute("id",admin.getId());        return actionMapping.findForward("success");    }}

⌨️ 快捷键说明

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