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

📄 office_gqxxfbaction.java

📁 这个程序是花了好几十万请人开发的
💻 JAVA
字号:
/* *  * @author 郑文金 * * 这个action用于在"网上办公室"中发布供求信息 * */package struts.action;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import javax.servlet.http.HttpSession;import org.apache.struts.action.ActionError;import org.apache.struts.action.ActionErrors;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 struts.form.Office_gqxxfbForm;import java.io.*;import javabean.*;import org.apache.struts.upload.FormFile;import java.sql.*;public class Office_gqxxfbAction extends Action {	private ConnectionPool pool;	private Connection con;	public Office_gqxxfbAction() throws SQLException	{		pool=ConnectionPool.getInstance();               //初始化连接池		  	}	public ActionForward execute(		ActionMapping mapping,		ActionForm form,		HttpServletRequest request,		HttpServletResponse response)		throws Exception 	{		Office_gqxxfbForm gqxxfbForm = (Office_gqxxfbForm) form;		HttpSession session=request.getSession();		ActionErrors errors=new ActionErrors();		CodeString getstring=new CodeString();//定义字符转换的函数				String Uid=(String)session.getAttribute("uid");//设置用户uid号				String Name=gqxxfbForm.getNAME();						String Spec=gqxxfbForm.getSPEC();						String Stype=gqxxfbForm.getSTYPE();						String Kind=gqxxfbForm.getKIND();						String Price=gqxxfbForm.getPRICE();						String Describe=gqxxfbForm.getDESCRIBE();						int Quantity=gqxxfbForm.getQUANTITY();				String Edate=gqxxfbForm.getEDATE();						String Area=gqxxfbForm.getAREA();						FormFile Photo=gqxxfbForm.getPHOTO();		String fname=Photo.getFileName();//获取文件名称		String dir=servlet.getServletContext().getRealPath("/photo");//设置文件存放的目录		InputStream streamIn=Photo.getInputStream();//定义一个输入流						String Photopath=dir+"/"+Uid+fname;//获取文件的路径		IOStream iostream=new IOStream();		if(!iostream.IOHandle(Photopath,streamIn))		{			errors.add("readerror",new ActionError("read_error"));			saveErrors(request,errors);		}				String Flag="false";//获取信息是否被审核的标志				PubDate date=new PubDate();		String FbDate=date.getshortPubdate();//获取发布信息时的时间;						con=pool.getConnection();  //从池中获得一个连接 		Cpgqbdao cpgq= new Cpgqbdao(con);				if(cpgq.con!=null)//如果数据库连接成功,就可以提交表单的数据		{			int Id=0;				String s1="select max(ID) as n from cpgqb";			ResultSet rs1=cpgq.executeQuery(s1);			while(rs1.next())			{				Id=rs1.getInt("n");			}			Id=Id+1;//编号自动加1					String s2="insert into Cpgqb values("+"'"+Id+"'"+","+"'"+Uid+"'"+","+"'"+Name+"'"+","+"'"+Stype+"'"+","+"'"+Kind+"'"+","+"'"+Describe+"'"+","+"'"+Spec+"'"+","+"'"+Area+"'"+","+"'"+Quantity+"'"+","+"'"+Price+"'"+","+"'"+FbDate+"'"+","+"'"+Edate+"'"+","+"'"+Flag+"'"+","+"'"+Photopath+"'"+" )";					cpgq.insert(s2);						int fabu=0;			String s3="select max(FABU) as fabu from member where UUID= "+"'"+Uid+"'";			ResultSet rs2=cpgq.executeQuery(s3);			while(rs2.next())			{				fabu=rs2.getInt("fabu");			}			fabu=fabu+1;			String s4="update member set fabu= "+"'"+fabu+"'"+" where UUID="+"'"+Uid+"'";			cpgq.insert(s4);//更新用户发布信息的条数			String msg=cpgq.insert(s4);//获得是否发布成功的标志			request.setAttribute("msg",msg);			cpgq.con.commit();			cpgq.con.close();						gqxxfbForm.reset(mapping,request);			if(msg.equals("success"))			{				return mapping.findForward("office_gqxxfb_confirm");			}			else				return mapping.findForward("office_gqxxfb");			}		else//如果数据库连接失败,就返回连接失败的页面!		{			return mapping.findForward("DbErrorPage");		}	}}

⌨️ 快捷键说明

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