public void addUpLoadFile(HTTPContext context) throws IOException { ServletFileUpload upload = new ServletFileUpload(new DiskFileItemFactory()); upload.setHeaderEncoding("utf-8"); List fileList = null; try { fileList = upload.parseRequest(context.request); } catch (FileUploadException ex) { ex.printStackTrace(); } Iterator it = fileList.iterator(); while (it.hasNext()) { FileItem item = (FileItem) it.next(); if (!item.isFormField()) { String name = item.getName(); if (item.getName() == null || item.getName().trim().equals("")) { continue; } byte[] docBytes = IOUtils.toByteArray(item.getInputStream()); String fileType=item.getName().substring(item.getName().lastIndexOf(".")+1); byte[] pdfBytes = null; SEntity sEntity = new SEntity("SYS_UPLOAD_FILE"); sEntity.setValue("CONTENT", docBytes); sEntity.setValue("FILENAME", name); sEntity.setValue("FILETYPE",fileType); baseDao.save(sEntity); context.reply("上传成功!", 200); } }