@@ -0,0 +1,1970 @@
+package upload;%0A%0Aimport java.io.File;%0Aimport java.io.IOException;%0Aimport java.io.PrintWriter;%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0Aimport javax.servlet.http.HttpServletRequest;%0Aimport javax.servlet.http.HttpServletResponse;%0A%0Aimport org.apache.commons.fileupload.FileItem;%0Aimport org.apache.commons.fileupload.FileUploadException;%0Aimport org.apache.commons.fileupload.disk.DiskFileItemFactory;%0Aimport org.apache.commons.fileupload.servlet.ServletFileUpload;%0A%0Aimport com.fasterxml.jackson.databind.ObjectMapper;%0A/**%0A * @author %E5%BE%90%E5%85%B4%E7%B9%81%0A * yntravelsky%0A * 2014-11-17%0A * %E8%BF%90%E8%A1%8C%E7%8E%AF%E5%A2%83windwos%0A *%E4%B8%8A%E4%BC%A0%0A */%0Apublic class upload %7B%0A   public String uploadfile(HttpServletRequest request, HttpServletResponse response,String target, String ROOT) throws IOException%7B%0A%09   if (!ServletFileUpload.isMultipartContent(request)) %7B%0A           throw new IllegalArgumentException(%22Request is not multipart, please 'multipart/form-data' enctype for your form.%22);%0A       %7D %0A       ServletFileUpload uploadHandler = new ServletFileUpload(new DiskFileItemFactory());%0A       PrintWriter writer = response.getWriter();%0A       response.setContentType(%22text/html%22);%0A       ArrayList%3C?%3E filelist = new ArrayList();%0A       try %7B%0A           List%3CFileItem%3E items = uploadHandler.parseRequest(request);%0A           for (FileItem item : items) %7B%0A               if (!item.isFormField()) %7B%0A                       File file = new File(request.getServletContext().getRealPath(%22/%22)+ROOT+target, item.getName());%0A                       item.write(file); %0A                       return file.getName();%0A               %7D%0A           %7D%0A       %7D catch (FileUploadException e) %7B%0A               throw new RuntimeException(e);%0A       %7D catch (Exception e) %7B%0A               throw new RuntimeException(e);%0A       %7D finally %7B%0A           ObjectMapper mapper = new ObjectMapper(); %0A%09%09%09String data=mapper.writeValueAsString(filelist);%0A           writer.write(data);%0A           writer.close();%0A       %7D%0A      return %22%22;%0A%0A   %7D%0A  %0A%7D%0A

Create upload.java