📄 fabuaction.java
字号:
//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 java.sql.ResultSet;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 FabuAction 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("开始fabuaction"); String depts[] = request.getParameterValues("dept"); String time = request.getParameter("time"); String jinji = request.getParameter("jinji"); String shixian = request.getParameter("ret"); System.out.println(time); String FCKeditor1s[] = request.getParameterValues("FCKeditor1"); String FCKeditor1 = ""; System.out.println( FCKeditor1s.length); 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.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 = "select id from v_tab"; System.out.println(sql); ResultSet rs = data.getResulSet(sql); String id = ""; rs.next(); id = new Integer(rs.getInt("id")).toString(); if(id.equals("")||id == null){ id = "0"; }else{ id = new Integer(new Integer(id).intValue()+1).toString(); } System.out.println(id); DataControl datay = new DataControl(); String sqly = "insert into fabu(id,timea,title,jinji,content,shixian) values('"+id+"','"+time+"','"+title+"','"+jinji+"','"+FCKeditor1+"','"+shixian+"')"; System.out.println(sqly); int i = datay.getInsert(sqly); System.out.println(i); 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(); } data.close(); datay.close(); session.setAttribute("ok","文件发布成功"); }catch(Exception e){ System.out.println("发布文件失败"+e.getStackTrace()); err.add("err",new ActionMessage("fabu.error","文件发布失败")); this.saveErrors(request,err); return mapping.getInputForward(); } return mapping.findForward("ok"); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -