updatedeptaction.java

来自「为基于J2EE(Java2 Platform」· Java 代码 · 共 59 行

JAVA
59
字号
//Created by MyEclipse Struts// XSL source (default): platform:/plugin/com.genuitec.eclipse.cross.easystruts.eclipse_4.0.1/xslt/JavaClass.xslpackage com.huang.actions;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 com.huang.common.DB.DBtool;import com.huang.forms.UpdateDeptForm;public class UpdateDeptAction extends Action {	public ActionForward execute(		ActionMapping mapping,		ActionForm form,		HttpServletRequest request,		HttpServletResponse response) {		UpdateDeptForm updateDeptForm = (UpdateDeptForm) form;						String index = (String)request.getParameter("index");						if(index.equals("first")) {			String dept_id = (String)request.getParameter("dept_id");			String sql = "select dept_name from tb_dept where dept_id="+dept_id+"";			String dept_name = DBtool.getOneString(sql);			if(dept_name!=null) {					request.setAttribute("dept_id",dept_id);										request.setAttribute("dept_name",dept_name);					return mapping.findForward("fail");			}					}		if(index.equals("update")) {			String dept_id = request.getParameter("dept_id");			String dept_name = updateDeptForm.getDept_name();			String sql = "update tb_dept set dept_name = '"+dept_name+"' where dept_id = "+dept_id+"";			if(DBtool.updateData(sql)) {				return mapping.findForward("success");			}		}						return mapping.findForward("success");	}}

⌨️ 快捷键说明

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