JSP ×é¼þÉÏ´«Îļþ£¨common fileupload£©
µÚ1¸öÉÏ´«×é¼þcommons-fileupload
=============commons-fileupload ================
common-fileupload×é¼þÊÇapacheµÄÒ»¸ö¿ªÔ´ÏîÄ¿Ö®Ò»£¬¿ÉÒÔ´Óhttp://jakarta.apache.org/commons/fileupload/ÏÂÔØ¡£¸Ã×é¼þ¼òµ¥Ò×Ó㬿ÉʵÏÖÒ»´ÎÉÏ´«Ò»¸ö»ò¶à¸öÎļþ£¬²¢¿ÉÏÞÖÆÎļþ´óС¡£
-ÏÂÔغó½âѹzip°ü£¬½«commons-fileupload-1.1.1.jar,ºÍcommons-io-1.2.jar¸´ÖƵ½tomcatµÄwebapps\ÄãµÄwebapp\WEB-INF\lib\Ï£¬Èç¹ûĿ¼²»´æÔÚÇë×Ô½¨Ä¿Â¼¡£
н¨Ò»¸öservlet: FileUpload.javaÓÃÓÚÎļþÉÏ´«£º
package com.drp.util.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.fileupload.*;
import java.util.*;
import java.util.regex.*;
import java.io.*;
import org.apache.commons.fileupload.servlet.*;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
public class FileUpload extends HttpServlet {
private String uploadPath = ""; // ÓÃÓÚ´æ·ÅÉÏ´«ÎļþµÄĿ¼
private File tempPath = new File("D:\\Tomcat 5.5\\webapps\\drp1.2\\tempimages\\"); // ÓÃÓÚ´æ·ÅÁÙʱÎļþµÄĿ¼
public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
res.setContentType("text/html; charset=GB18030");
PrintWriter out = res.getWriter();
System.out.println(req.getContentLength());
System.out.println(req.getContentType());
DiskFileItemFactory factory = new DiskFileItemFactory();
// maximum size that will be stored in memory
//ÔÊÐíÉèÖÃÄÚ´æÖд洢Êý¾ÝµÄÃÅÏÞ£¬µ¥Î»£º×Ö½Ú
factory.setSizeThreshold(4096);
// the location for saving data that is larger than getSizeThreshold()
//Èç¹ûÎļþ´óС´óÓÚSizeThreshold£¬Ôò±£´æµ½ÁÙʱĿ¼
factory.setRepository(new File("D:\\Tomcat 5.5\\webapps\\drp1.2\\tempimages"));
ServletFileUploa
Ïà¹ØÎĵµ£º
title: JSP·ÖÒ³¼¼ÊõʵÏÖ
summary:ʹÓù¤¾ßÀàʵÏÖͨÓ÷ÖÒ³´¦Àí
author: evan_zhao
email: evan_zhao@hotmail.com
¡¡¡¡Ä¿Ç°±È½Ï¹ã·ºÊ¹ÓõķÖÒ³·½Ê½Êǽ«²éѯ½á¹û»º´æÔÚHttpSession»òÓÐ״̬beanÖУ¬·Ò³µÄʱºò´Ó»º´æÖÐÈ¡³öÒ»Ò³Êý¾ÝÏÔʾ¡£ÕâÖÖ·½·¨ÓÐÁ½¸öÖ÷ÒªµÄȱµã£ºÒ»ÊÇÓû§¿ÉÄÜ¿´µ½µÄÊǹýÆÚÊý¾Ý£»¶þÊÇÈç¹ûÊ ......
ÔÚMyEclipseÖпª·¢WEBÓ¦ÓÃʱ¾³£Òª´´½¨JSPÎļþ£¬µ«ÊÇÿ´ÎMyEclipse¶¼»áÓÃĬÈϵÄMyEclipse Visual JSP Designer£¬´ò¿ªËٶȷdz£Âý£¬¶øÇÒ»ù±¾ÉÏÒ²Óò»µ½Õâ¸ö¿ÉÊÓ»¯µÄJSP±à¼Æ÷£¬¶à°ë¶¼ÊÇʹÓÃMyEclipse JSP Editor£¬ËùÒÔ£¬ÓбØÒª°ÑĬÈϵÄJSPÎļþ±à¼Æ÷¸Ä³ÉMyEclipse JSP Editor£¬·½±ãʹÓã¬Ò²¿É ......
ÎÒÏÖÔÚ¸øÄãÒ»¸öJAVAºÍJSPÖ®¼äµÄ¹Øϵ,ÒÔ¼°JAVAµÄÍêÕûÈÏʶ
JAVA·ÖΪJ2EE,J2SE.J2ME,ÏÂÃæ·Ö±ð½éÉÜ:
Ò».J2EE£ºJava 2 Platform Enterprise Edition ÆóÒµ°æ£¬ÓÃÓÚÆóÒµÓ¦Óã¬Ö§³Ö·Ö²¼Ê½²¿Êð¡£
J2EEƽ̨ÓÉÒ»ÕûÌ×·þÎñ£¨Services£©¡¢Ó¦ÓóÌÐò½Ó¿Ú£¨APIs£©ºÍÐÒé¹¹³É£¬
Ëü¶Ô¿ª·¢»ùÓÚWebµÄ¶à²ãÓ¦ÓÃÌṩÁ˹¦ÄÜÉϵÄÖ§³Ö¡£Ëü°ü ......
Ò»¡¢JSPµÄ¼¼ÊõÔÀí
¶þ¡¢JSPµÄ×¢ÊͺÍÉùÃ÷
JSP×¢ÊÍÓÃÓÚ±íÃ÷ÔÚ³ÌÐò¿ª·¢¹ý³ÌÖеĿª·¢Ìáʾ£¬²»»áÊä³öµ½¿Í»§¶Ë£»
<%--×¢ÊÍÄÚÈÝ--%> —— JSP×¢ÊÍ
<£¡--×¢ÊÍÄÚÈÝ--£¡> —&md ......
ÈçºÎÓÃJBoss ......