updatefabuaction.java

来自「这是一个简单的办公管理系统」· Java 代码 · 共 87 行

JAVA
87
字号
//Created by MyEclipse Struts// XSL source (default): platform:/plugin/com.genuitec.eclipse.cross.easystruts.eclipse_4.1.1/xslt/JavaClass.xslpackage com.yourcompany.struts.action;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import javax.servlet.http.HttpSession;import org.apache.struts.action.Action;import org.apache.struts.action.ActionErrors;import org.apache.struts.action.ActionForm;import org.apache.struts.action.ActionForward;import org.apache.struts.action.ActionMapping;import org.apache.struts.action.ActionMessage;import admin.DataControl;public class UpdatefabuAction extends Action {	public ActionForward execute(		ActionMapping mapping,		ActionForm form,		HttpServletRequest request,		HttpServletResponse response) {		ActionErrors err = new ActionErrors(); 		HttpSession session = request.getSession();		try{			request.setCharacterEncoding("GBK");			System.out.println("");			System.out.println("开始updatefabuaction");			String depts[] = request.getParameterValues("dept");			String id = request.getParameter("id");			System.out.println(id);			String jinji = request.getParameter("jinji");			System.out.println(jinji);			String shixian = request.getParameter("ret");			System.out.println(shixian);			String FCKeditor1s[] = request.getParameterValues("FCKeditor1");			String FCKeditor1 = "";			for (int x = 0; x < FCKeditor1s.length; x++) {				FCKeditor1 = FCKeditor1+FCKeditor1s[x];			}			System.out.println(FCKeditor1.length());			if(FCKeditor1.length()>8000){	   			err.add("err",new ActionMessage("fabu.update.error","申请内容不得大于8000字"));				this.saveErrors(request,err);				return mapping.getInputForward();			}			FCKeditor1 = FCKeditor1.replace("'","''");			System.out.println("titles.length: "+FCKeditor1s.length);			System.out.println(FCKeditor1);			String title = request.getParameter("title");			title = title.replace("'","''");			System.out.println(title);			DataControl data = new DataControl();					String sql = "update fabu set jinji='"+jinji+"',shixian='"+shixian+"',title='"+title+"',content='"+FCKeditor1+"' where id="+id;			System.out.println(sql);			int i = data.getUpdate(sql);			System.out.println(i);						DataControl data1 = new DataControl();			String sql1 = "delete from fabudept where fabuid="+id;			int i1 = data1.getDelete(sql1);			System.out.println(i1);			data1.close();						for (int x = 0; x < depts.length; x++) {				DataControl datax = new DataControl();				String sqlx = "insert into fabudept values("+id+",'"+depts[x]+"',0)";                int ix = datax.getInsert(sqlx);				System.out.print(ix);				datax.close();			}						session.setAttribute("ok","文件修改成功");		}catch(Exception e){			System.out.println("修改文件失败"+e.getStackTrace());   			err.add("err",new ActionMessage("fabu.update.error","文件修改失败"));			this.saveErrors(request,err);			return mapping.getInputForward();		}		return mapping.findForward("ok");	}}

⌨️ 快捷键说明

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