📄 appendaction.java
字号:
/*
* Copyright Neusoft Dalian Center,All Rights Reserved
*
* WEB Application Apply Struts Platform
*
* PackageName shengjb.form
* ClassName AppendAction.java
*
* @author shengjb | shengjb@neusoft.com
*
* Created on 2005-4-15
*
*/
package shengjb.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import shengjb.form.AppendForm;
import shengjb.model.AppendBean;
import zhangchunliang.model.AppMode;
/**
* AppendAction ActionClass
*
* @author shengjb ver.0.7
*/
public class AppendAction extends Action {
/**
* Process the specified HTTP request, and create the corresponding HTTP
* response (or forward to another web component that will create it), with
* provision for handling exceptions thrown by the business logic. Return an
* {@link ActionForward}instance describing where and how control should be
* forwarded, or <code>null</code> if the response has already been
* completed.
*
* @param mapping
* The ActionMapping used to select this instance
* @param form
* The optional ActionForm bean for this request (if any)
* @param request
* The HTTP request we are processing
* @param response
* The HTTP response we are creating
* @exception Exception
* if the application business logic throws an exception
* @since Struts 1.1
*/
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
if(!AppMode.getAppMode()){
System.out.println("Application is terminated...");
return mapping.findForward("appInfo");
}
/*获得表单里的员工号,姓名,密码,部门号,组号*/
String userID = request.getParameter("userID");
String userName = request.getParameter("userName");
String password = request.getParameter("password");
String departmentNo = request.getParameter("departmentNo");
String[]groupNo= request.getParameterValues("groupNo");
/*Form对象实例化 */
AppendForm appendForm = (AppendForm)form;
/*把获得的值SET到自定义的 FORM 中去*/
appendForm.setUserID(userID);
appendForm.setUserName(userName);
appendForm.setPassword(password);
appendForm.setDepartmentNo(departmentNo);
appendForm.setGroupNo(groupNo);
/*
* Having received and valiated the data submitted from the View,we now
* update the database,call the model
*/
AppendBean appendBean = new AppendBean();
/*获得append()方法的返回值,根据此返回值进行跳转*/
String info = appendBean.append(appendForm);
/*remove the Form Bean don't need to carry value forward*/
request.removeAttribute(mapping.getAttribute());
if(info == "sidrepeation"){
/*Forward control to the specified Sid repeation URI*/
return (mapping.findForward("sidrepeation"));
}else if(info =="adminothererror"){
/*Forward control to the adminother error URI*/
return (mapping.findForward("adminothererror"));
}else if(info == "appendsuccess"){
/*Forward control to the specified append success URI*/
return (mapping.findForward("appendsuccess"));
}else{
/*Forward control to the specified append faile URI*/
return (mapping.findForward("appendfaile"));
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -