private void doFileUpload(HttpSession session, HttpServletRequest request,
HttpServletResponse response) throws IOException {
response.setContentType("text/html;charset=utf-8");
try {
//创建UploadListener对象
UploadListener listener = new UploadListener(request.getContentLength());
listener.start();//启动监听状态
//将监听器对象的状态保存在Session中
session.setAttribute("FILE_UPLOAD_STATS", listener.getFileUploadStats());
//创建MonitoredDiskFileItemFactory对象
FileItemFactory factory = new MonitoredDiskFileItemFactory(listener);
//通过该工厂对象创建ServletFileUpload对象
ServletFileUpload upload = new ServletFileUpload(factory);
//将转化请求保存到list对象中
List items = upload.parseRequest(request);
//停止使用监听器
listener.done();
boolean hasError = false;
//循环list中的对象
for (Iterator i = items.iterator(); i.hasNext();) {
FileItem fileItem = (FileItem) i.next();
if (!fileItem.isFormField()) {//如果该FileItem不是表单域