欢迎来到天天文库
浏览记录
ID:2137389
大小:134.50 KB
页数:10页
时间:2017-11-14
《软件架构课程设计》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、软件架构课程设计—电子相册管理系统专业:软件工程姓名:樊帆学号:200705070313packagehbu.david.cmc.util;/***通用文件上传类,对FileUpload的包装*/importjava.io.File;importjava.io.FileInputStream;importjava.io.FileOutputStream;importjava.io.IOException;importjava.io.PrintWriter;importjava.io.UnsupportedEncodingE
2、xception;importjava.util.ArrayList;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.htt
3、p.HttpServletRequest;importjavax.servlet.http.HttpServletResponse;importorg.apache.commons.fileupload.FileItem;importorg.apache.commons.fileupload.FileItemFactory;importorg.apache.commons.fileupload.FileUpload;importorg.apache.commons.fileupload.FileUploadExceptio
4、n;importorg.apache.commons.fileupload.disk.DiskFileItemFactory;importorg.apache.commons.fileupload.servlet.ServletFileUpload;importhbu.david.cmc.http.ServletEncoding;importhbu.david.cmc.util.*;importhbu.david.cmc.bean.*;publicclassFileUploadUtil{/***初始化,获取FileItem
5、的列表并返回*/publicstaticListinit(HttpServletRequestrequest,HttpServletResponseresponse){ServletEncoding.setEncoding(request,response);ListlistFileItem=newArrayList();//MapfileUpInfo=newHashMap();//List6、em>list=newArrayList();FileItemFactoryfactory=newDiskFileItemFactory();ServletFileUploadservletFileUpload=newServletFileUpload(factory);servletFileUpload.setFileSizeMax(4096*4096);try{//获取request中包含的FileItemslistFileItem=servletFileUpload.parseRequest(re7、quest);}catch(FileUploadExceptione){System.out.print("sizeistoobig");}returnlistFileItem;}/***获取文件域信息保存在Map**@paramfileItems*@return*/publicstaticMapgetFile(ListfileItems){MapmapFiles=newHashMap8、ileItem>();for(inti=0;i
6、em>list=newArrayList();FileItemFactoryfactory=newDiskFileItemFactory();ServletFileUploadservletFileUpload=newServletFileUpload(factory);servletFileUpload.setFileSizeMax(4096*4096);try{//获取request中包含的FileItemslistFileItem=servletFileUpload.parseRequest(re
7、quest);}catch(FileUploadExceptione){System.out.print("sizeistoobig");}returnlistFileItem;}/***获取文件域信息保存在Map**@paramfileItems*@return*/publicstaticMapgetFile(ListfileItems){MapmapFiles=newHashMap8、ileItem>();for(inti=0;i
8、ileItem>();for(inti=0;i
此文档下载收益归作者所有