⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 updateprofessionaction.java

📁 为基于J2EE(Java2 Platform
💻 JAVA
字号:
//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 java.util.ArrayList;import java.util.HashMap;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.common.tool.Tools;import com.huang.forms.UpdateProfessionForm;public class UpdateProfessionAction extends Action {	public ActionForward execute(		ActionMapping mapping,		ActionForm form,		HttpServletRequest request,		HttpServletResponse response) {		UpdateProfessionForm updateProfessionForm = (UpdateProfessionForm) form;				String index = (String)request.getParameter("index");				if(index.equals("first")) {			String profession_id = (String)request.getParameter("id");			ArrayList list = DBtool.getDataList("tb_profession",new String[]{"profession_name","dept_id"},"profession_id='"+profession_id+"'");			String profession_name = ((HashMap)list.get(0)).get("profession_name").toString();			String dept_id = ((HashMap)list.get(0)).get("dept_id").toString();			String sql = "select dept_name from tb_dept where dept_id="+dept_id;			String dept_name = DBtool.getOneString(sql);									if(profession_name!=null) {				request.setAttribute("profession_id",profession_id);					request.setAttribute("profession_name",profession_name);				request.setAttribute("dept_id",dept_id);				request.setAttribute("dept_name",dept_name);				ArrayList dept_list = DBtool.getDataList("tb_dept",new String[]{"dept_id","dept_name"}); 				request.setAttribute("dept",dept_list);				return mapping.findForward("fail");			}					}		if(index.equals("update")) {			String profession_id = (String)request.getParameter("id");			String profession_name = updateProfessionForm.getProfession_name();			String dept_id = updateProfessionForm.getDept_id();			String sql = "update tb_profession set profession_name = '"+profession_name+"',dept_id='"+dept_id+"' where profession_id = "+profession_id+"";			if(DBtool.updateData(sql)) {				return mapping.findForward("success");			}		}				return mapping.findForward("success");	}}

⌨️ 快捷键说明

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