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

📄 upbook.java

📁 这是一个网上书站的例子
💻 JAVA
字号:
/*
 * Generated by MyEclipse Struts
 * Template path: templates/java/JavaClass.vtl
 */
package com.zxf.struts.book;

import java.io.InputStream;

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 org.apache.struts.upload.FormFile;

import com.db.Jdo;
import com.string.StringOper;
import com.upfile.UpFile;

/** 
 * MyEclipse Struts
 * Creation date: 01-08-2008
 * 
 * XDoclet definition:
 * @struts.action path="/upbook" name="upbookForm" scope="request"
 */
public class UpBook extends Action {
	/*
	 * Generated Methods
	 */

	/** 
	 * Method execute
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 */
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		// TODO Auto-generated method stub
		UpBookForm upform=(UpBookForm)form;
		String bookname=upform.getBookname();
		String price=upform.getPrice();
		String count=upform.getCount();
		String agio=upform.getAgio();
		String press=upform.getPress();
		String pressdate=upform.getPressdate();
		String ibsn=upform.getIbsn();
		String types=upform.getTypes();
		String author=upform.getAuthor();
		FormFile file=upform.getUpFile();
		String content=upform.getContent();
		
		if(file==null)
		{
			return mapping.findForward("error");
		}
		
		String newname;
		String filename=file.getFileName();
		try 
		{
			newname=StringOper.getFileName(filename);
			InputStream is=file.getInputStream();
			String storePath=servlet.getServletContext().getRealPath("/");
			UpFile upfile=new UpFile(storePath,is,newname);
			upfile.upfileToserver();
			Jdo jdo=new Jdo();
			jdo.executeUpdate("insert into book(author,bookname,bookprice,remaincount,bookagio,press,pressdate,ibsn,smallcatalogid,bmpurl,content) values('"+author+"','"+bookname+"',"+price+","+count+","+agio+",'"+press+"','"+pressdate+"','"+ibsn+"',"+types+",'"+newname+"','"+content+"')");
			
			jdo.destroy();
				
		} 
		
		catch (Exception e)
		{
				
			e.printStackTrace();
			//return mapping.findForward("error");
		}
		return mapping.findForward("sucess");
	}
}

⌨️ 快捷键说明

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