javaÓÃCommons fileupload ÎļþµÄÉÏ´«
»ùÓÚ±íµ¥µÄÎļþÉÏ´«
Èç¹ûÔÚ±íµ¥ÖÐʹÓÃ±íµ¥ÔªËØ <input type=“file”
/>£¬ä¯ÀÀÆ÷ÔÚ½âÎö±íµ¥Ê±£¬»á×Ô¶¯Éú³ÉÒ»¸öÊäÈë¿òºÍÒ»¸ö°´Å¥£¬ÊäÈë¿ò¿É¹©Óû§Ìîд±¾µØÎļþµÄÎļþÃûºÍ·¾¶Ãû£¬°´Å¥¿ÉÒÔÈÃä¯ÀÀÆ÷´ò¿ªÒ»¸öÎļþÑ¡Ôñ¿ò¹©
Óû§Ñ¡ÔñÎļþ£º
µ±±íµ¥ÐèÒªÉÏ´«Îļþʱ£¬ÐèÖ¸¶¨±íµ¥ enctype µÄֵΪ multipart/form-data
ÔÚ form ÔªËصÄÓï·¨ÖУ¬enctype ÊôÐÔÖ¸¶¨½«Êý¾Ý·¢Ë͵½·þÎñÆ÷ʱä¯ÀÀÆ÷ʹÓõıàÂëÀàÐÍ¡£
enctype ÊôÐÔÈ¡Öµ:
application/x-www-form-urlencoded£º±íµ¥ enctype
ÊôÐÔµÄĬÈÏÖµ¡£ÕâÖÖ±àÂë·½°¸Ê¹ÓÃÓÐÏÞµÄ×Ö·û¼¯£¬µ±Ê¹ÓÃÁË·Ç×ÖĸºÍÊý×Öʱ£¬±ØÐëÓÔ%HH”´úÌæ(H ´ú±íÊ®Áù½øÖÆÊý×Ö)¡£¶ÔÓÚ´óÈÝÁ¿µÄ¶þ½øÖÆÊý¾Ý»ò°üº¬·Ç
ASCII ×Ö·ûµÄÎı¾À´Ëµ£¬ÕâÖÖ±àÂë²»ÄÜÂú×ãÒªÇó¡£
multipart/form-data
£ºform
É趨ÁËenctype=“multipart/form-data”ÊôÐԺ󣬱íʾ±íµ¥ÒÔ¶þ½øÖÆ´«ÊäÊý¾Ý .
Commons-fileupload ×é¼þÉÏ´«µÄ»ù±¾ÔÀí
FileUpload×é¼þ½«Ò³ÃæÌá½»µÄËùÓÐÔªËØ(ÆÕͨform±íµ¥Óò£¬ÈçtextºÍÎļþÓòfile)¶¼¿´×÷Ò»ÑùµÄFileItem£¬ÕâÑùÉÏ´«Ò³ÃæÌá
½»µÄ
requestÇëÇóÒ²¾ÍÊÇÒ»¸öFileItemµÄÓÐÐò×éºÏ£¬FileUpload×é¼þ¿ÉÒÔ½âÎö¸Ãrequest£¬²¢·µ»ØÒ»¸öÒ»¸öµÄFileItem¡£¶ø¶Ô
ÿһ¸öFileItem£¬FileUpload×é¼þ¿ÉÒÔÅжϳöËüÊÇÆÕͨform±íµ¥Óò»¹ÊÇÎļþfileÓò£¬´Ó¶ø¸ù¾Ý²»Í¬µÄÀàÐÍ£¬²ÉÈ¡²»Í¬µÄ²Ù×÷££Èç¹ûÊÇ
±íµ¥Óò£¬¾Í¶Á³öÆäÖµ£¬Èç¹ûÊÇÎļþÓò£¬¾Í±£´æÎļþµ½·þÎñÆ÷Ó²ÅÌÉÏ»òÕßÄÚ´æÖÐ
Commons-fileupload ×é¼þAPI
ServletFileUpload
¸ºÔð´¦ÀíÉÏ´«µÄÎļþÊý¾Ý£¬²¢½«Ã¿²¿·ÖµÄÊý¾Ý·â×°³ÉÒ»µ½ FileItem ¶ÔÏóÖС£
DiskFileItemFactory
ÊÇ´´½¨
FileItem ¶ÔÏóµÄ¹¤³§£¬ÔÚÕâ¸ö¹¤³§ÀàÖпÉÒÔÅäÖÃÄڴ滺³åÇø´óСºÍ´æ·ÅÁÙʱÎļþµÄĿ¼¡£
ServletFileUpload
ÔÚ½ÓÊÕÉÏ´«ÎļþÊý¾Ýʱ£¬»á½«ÄÚÈݱ£´æµ½Äڴ滺´æÇøÖУ¬Èç¹ûÎļþÄÚÈݳ¬¹ýÁË DiskFileItemFactory
Ö¸¶¨µÄ»º³åÇøµÄ´óС£¬ÄÇôÎļþ½«±»±£´æµ½´ÅÅÌÉÏ£¬´æ´¢Îª DiskFileItemFactory
Ö¸¶¨Ä¿Â¼ÖеÄÁÙʱÎļþ¡£µÈÎļþÊý¾Ý¶¼½ÓÊÕÍê±Ïºó£¬ServletUpload ÔÚ´ÓÎļþÖн«Êý¾ÝдÈëµ½ÉÏ´«ÎļþĿ¼ÏµÄÎļþÖÐ
½øÐÐÎļþÉÏ´«µÄ¾ßÌå²Ù×÷£º
Ê×ÏÈ£¬¼ÓÔرØÒªµÄjar°ü£º“commons-fileupload-1.2.1.jar”
//ʹÓà FileUpload ×é¼þ½âÎö±íµ¥£º
DiskFileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
//
Ïà¹ØÎĵµ£º
Ëõ·ÅͼÏñµÄ»ù±¾ÔÀíÊÇ´´½¨Ò»¸öÄ¿±ê´óСµÄ»²¼£¬È»ºó¶ÁȡԴͼÏñ£¬²¢½«¸ÃͼÏñ»æÖÆÕâ¸ö»²¼ÉÏ¡£ÎªÁËʹ³ÌÐòͨÓã¬Ô´Í¼ÏñºÍËõ·ÅºóµÄÄ¿±êͼÏñÓ¦Ó÷ֱðʹÓà InputStreamºÍOutputStreamÀ´±íʾ£¬´úÂëÈçÏ£º
public static void scaleImage(InputStream imgInputStrea ......
½ñÌìÔÚ±àдһ¸ö¿ìËÙÅÅÐòº¯Êý£¬ÆäÖÐÏëÓÃÒ»¸öÔÚC++ÖÐÀàËÆswap¹¦Äܵĺ¯Êý£¬½á¹ûÒý·¢ÁËһϵÁеÄÎÊÌâ¡£
ÏÂÃæÊÇÔÚÍøÉÏËѵ½µÄ´úÂ룬²¢ÔÚÎҵı¾µØ»úÉÏ×÷ÁËÔËÐС£
public class ParamTest
{
public static void ......
¶ÔÏóÐòÁл¯¾ÍÊǰѶÔÏóдÈëµ½Êä³öÁ÷ÖУ¬ÓÃÀ´´æ´¢»òÕß´«Êä¡£
¶ÔÏóµÄ·´ÐòÁл¯¾ÍÊÇ´ÓÊäÈëÁ÷ÖжÁÈ¡¶ÔÏó¡£
ÒªÐòÁл¯µÄ¶ÔÏóÓ¦¸ÃʵÏÖSerializable½Ó¿Ú¡£
Serializable½Ó¿ÚÊÇÒ»¸ö±êʶ½Ó¿Ú£¬Ã»ÓгéÏó·½·¨¡£
SerializableÓÐÒ»¸ö× ......
JavaÊÇÓÉSUN Microsystem¹«Ë¾¿ª·¢µÄ¡¢ÓÉC++·¢Õ¹¶øÀ´µÄÒ»ÖÖÃæÏò¶ÔÏóµÄͨÓóÌ
ÐòÉè¼ÆÓïÑÔ¡£Java²¢²»ÊÇרÃÅΪInternet¶ø¿ª·¢µÄ£¬µ«ËüµÄ³öÏÖµÄȷΪInternetºÍWWW
¿ª±ÙÁËÒ»¸öոеÄʱ´ú¡£Ëü¾ßÓÐÒÔÏÂһЩÌص㣻¼òµ¥¡¢ÃæÏò¶ÔÏó¡¢·Ö²¼Ê½¡¢Ç¿×³¡¢°²È«¡¢
Óë²Ù×÷ƽ̨Î޹ء¢¸ßÐÔÄÜ¡¢¶àÏß³ÌÒÔ¼°¶¯Ì¬ÐÔ¡£ ......
package com.color.program;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
public class CompareTime {
public static void main(String[] args){
String t1 = "2008-05-09";
String t2 = "20 ......