addemployeetodeptaction.java

来自「是jsp开发与应用详解的全部源代码」· Java 代码 · 共 35 行

JAVA
35
字号
package com.jspdev.ch18;

import org.apache.struts.action.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
public final class AddEmployeeToDeptAction extends Action {

    public ActionForward execute(ActionMapping mapping,
                                 ActionForm form,
                                 HttpServletRequest request,
                                 HttpServletResponse response)
        throws Exception {
        EmployeeBean service = new EmployeeBean();
        DynaActionForm f=(DynaActionForm)form;
        String employId=(String)f.get("employId");
        String deptId=(String)f.get("deptId");
		//String employId=request.getParameter("employId");
		//String deptId=request.getParameter("deptId");
        
        try {
             service.resetEmploy(employId,deptId);
              request.setAttribute("deptId",deptId);
            return (mapping.findForward("success"));
        }
        catch( Exception de ) {
            ActionErrors errors = new ActionErrors();
            ActionError error = new ActionError("error.employee.databaseException");
            errors.add( ActionErrors.GLOBAL_ERROR, error );
            saveErrors( request, errors );
            return (mapping.findForward("error"));
        }
    }
}

⌨️ 快捷键说明

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