zjxhx 发表于 2017-1-12 06:59:59

apache 的 common-fileupload-1.2.1.jar

  最近热衷于学习源码,主要是学习下前辈的优美的编程风格,顺便也学习下前辈们的编程思想。
  现在遇到一个无头的疑问。
  在我用到common-fileupload1.2.1.jar包时,看到

DiskFileItemFactory factory = new DiskFileItemFactory();
factory.setRepository(new File("f:/load"));
factory.setSizeThreshold(2048);
ServletFileUpload fileload = new ServletFileUpload(factory);
fileload.setFileSizeMax(1024 * 1024 * 20);
fileload.setHeaderEncoding("UTF-8");
System.out.println("aaaaaaaaaaaa");
//此处可以监听到上传多少数据。允许用户在网页展示动态的显示上传数据。
ProgressListener progressListener = new ProgressListener() {
public void update(long pBytesRead, long pContentLength,
int pItems) {
System.out.println("We are currently reading item "
+ pItems);
if (pContentLength == -1) {
System.out.println("So far, " + pBytesRead
+ " bytes have been read.");
} else {
System.out.println("So far, " + pBytesRead + " of "
+ pContentLength + " bytes have been read.");
}
}
};
fileload.setProgressListener(progressListener);
List items = fileload.parseRequest(request);
  List items =fileload.parseRequest(request);
  想看一看前辈是怎么处理request请求,然后再返回 FileItem的集合的。
  下载源码。
  找到 ServletFileUpload.java
  如下:
  public class ServletFileUpload extends FileUpload {
  public List /* FileItem */ parseRequest(HttpServletRequest request)
       throws FileUploadException {
          return parseRequest(new ServletRequestContext(request));
    }
  }
  但是搜索整个文档,也只有这么几个方法,但是 parseRequest(ServletRequestContext servletRequestContext)方法没有找到。
  思路一下断了,为什么呢。希望高人留言指点下。
  下面是源码
页: [1]
查看完整版本: apache 的 common-fileupload-1.2.1.jar