欢迎来到天天文库
浏览记录
ID:18817676
大小:134.50 KB
页数:10页
时间:2018-09-25
《软件架构课程设计》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、软件架构课程设计—电子相册管理系统专业:软件工程姓名:樊帆学号:200705070313packagehbu.david.cmc.util;/***通用文件上传类,对FileUpload的包装*/importjava.io.File;importjava.io.FileInputStream;importjava.io.FileOutputStream;importjava.io.IOException;importjava.io.PrintWriter;importjava.io.UnsupportedEncodingException;importjava.util.ArrayList
2、;importjava.util.HashMap;importjava.util.Iterator;importjava.util.List;importjava.util.Map;importjava.util.Set;importjava.util.UUID;importjavax.servlet.RequestDispatcher;importjavax.servlet.ServletException;importjavax.servlet.http.HttpServletRequest;importjavax.servlet.http.HttpServletResponse;im
3、portorg.apache.commons.fileupload.FileItem;importorg.apache.commons.fileupload.FileItemFactory;importorg.apache.commons.fileupload.FileUpload;importorg.apache.commons.fileupload.FileUploadException;importorg.apache.commons.fileupload.disk.DiskFileItemFactory;importorg.apache.commons.fileupload.ser
4、vlet.ServletFileUpload;importhbu.david.cmc.http.ServletEncoding;importhbu.david.cmc.util.*;importhbu.david.cmc.bean.*;publicclassFileUploadUtil{/***初始化,获取FileItem的列表并返回*/publicstaticListinit(HttpServletRequestrequest,HttpServletResponseresponse){ServletEncoding.setEncoding(request,respon
5、se);ListlistFileItem=newArrayList();//MapfileUpInfo=newHashMap();//Listlist=newArrayList();FileItemFactoryfactory=newDiskFileItemFactory();ServletFileUploadservletFileUpload=newServletFileUpload(factory);servletFileUpload.setFil
6、eSizeMax(4096*4096);try{//获取request中包含的FileItemslistFileItem=servletFileUpload.parseRequest(request);}catch(FileUploadExceptione){System.out.print("sizeistoobig");}returnlistFileItem;}/***获取文件域信息保存在Map**@paramfileItems*@return*/publicstaticMapgetFile(List7、>fileItems){MapmapFiles=newHashMap();for(inti=0;i
7、>fileItems){MapmapFiles=newHashMap();for(inti=0;i
此文档下载收益归作者所有