`

org.apache.commons.fileupload.FileUploadBase 系统找不到指定的路径

    博客分类:
  • java
 
阅读更多
写道
//创建解析工厂
DiskFileItemFactory factory = new DiskFileItemFactory();
factory.setRepository(new File(this.getServletContext().getRealPath("/WEB-INF/temp")));//设置文件缓存目录
factory.setSizeThreshold(1024*1024);
//创建解析器
ServletFileUpload upload = new ServletFileUpload(factory);
upload.setHeaderEncoding("UTF-8");
upload.setSizeMax(-1);
//解析request得到封装FileItem的list
try{
List<FileItem> list = upload.parseRequest(request);//list.size() is 0
for(int i=0; i<list.size(); i++) {
FileItem item = (FileItem)list.get(i);
if(!item.isFormField()){
String name = item.getName();

  1.temp目录是在程序中设定用来做文件上传的临时目录用的.

  2.被删掉后,文件大小超过设置的1024*1024字节后,就会使用到临时目录,这时如果临时目录没有,就会出现错误。

  3.重新在“/WEB-INF”目录下添加上“temp”目录,错误就解决了

分享到:
评论

相关推荐

    commons-fileupload.jar和commons-io.jar

    import org.apache.commons.fileupload.FileUploadBase.SizeLimitExceededException; import org.apache.commons.fileupload.disk.DiskFileItemFactory; import org.apache.commons.fileupload.servlet....

    利用commons-fileupload组件实现文件上传-实例

    import org.apache.commons.fileupload.FileUploadBase.SizeLimitExceededException; import org.apache.commons.fileupload.FileUploadException; import org.apache.commons.fileupload.disk.DiskFileItemFactory;...

    commons-fileupload-1.2.2

    《Apache Commons FileUpload详解》 Apache Commons FileUpload是Java领域中处理HTTP文件上传的一个强大工具,主要用于解析HTTP请求中的多部分表单数据。在本文中,我们将深入探讨这个库的1.2.2版本,包括它的核心...

    apache文件上传_apache文件上传_

    要使用Apache Commons FileUpload,首先需要将其添加到项目的类路径中。这可以通过在Maven的pom.xml文件中添加依赖或在构建路径中包含对应的JAR包来完成。以下是Maven的依赖配置示例: ```xml &lt;groupId&gt;commons-...

    使用commons-fileupload实现的文件上传和下载

    在Java Web开发中,文件上传和下载是常见的功能需求,Apache Commons FileUpload库提供了一种高效、方便的方式来处理这些操作。本教程将详细介绍如何利用commons-fileupload库来实现在Java Web应用中的文件上传和...

    如何在服务器端 读取Ext.ux.UploadDialog上传的文件?

    import org.apache.commons.fileupload.FileUploadBase.SizeLimitExceededException; import org.apache.commons.fileupload.disk.DiskFileItemFactory; import org.apache.commons.fileupload.servlet....

    jsp FileUpload 组件

    import org.apache.commons.fileupload.FileUploadBase.SizeLimitExceededException; import org.apache.commons.fileupload.disk.DiskFileItemFactory; import org.apache.commons.fileupload.servlet....

    java文件上传

    import org.apache.commons.fileupload.FileUploadBase.SizeLimitExceededException; import org.apache.commons.fileupload.FileUploadException; import org.apache.commons.fileupload.disk.DiskFileItemFactory;...

    fileupload上传demo

    import org.apache.commons.fileupload.FileUploadBase.SizeLimitExceededException; import org.apache.commons.fileupload.disk.DiskFileItemFactory; import org.apache.commons.fileupload.servlet....

    上传文件所需jar包

    import org.apache.commons.fileupload.FileUploadBase.SizeLimitExceededException; import org.apache.commons.fileupload.disk.DiskFileItemFactory; import org.apache.commons.fileupload.servlet....

    java上传文件到服务器

    import org.apache.commons.fileupload.FileUploadBase.SizeLimitExceededException; import org.apache.commons.fileupload.FileUploadException; import org.apache.commons.fileupload.disk.DiskFileItemFactory;...

    JAVA 图片上传 预览

    import org.apache.commons.fileupload.FileUploadBase.SizeLimitExceededException; import org.apache.commons.fileupload.disk.DiskFileItemFactory; import org.apache.commons.fileupload.servlet....

    apache的fileupload详解

    这篇博客文章深入讲解了如何使用Apache Commons FileUpload库来处理文件上传请求,以及相关的源码分析。 一、Apache Commons FileUpload简介 Apache Commons FileUpload是Apache软件基金会的一个开源项目,它提供了...

    jsp中的文件上传和下载

    import org.apache.commons.fileupload.FileUploadBase.SizeLimitExceededException; import org.apache.commons.fileupload.disk.DiskFileItemFactory; import org.apache.commons.fileupload.servlet....

    servlet 上传

    import org.apache.commons.fileupload.FileUploadBase.SizeLimitExceededException; import org.apache.commons.fileupload.disk.DiskFileItemFactory; import org.apache.commons.fileupload.servlet....

    comm-fileupload教程

    - 下载 Apache Commons FileUpload 最新版本:访问 `http://jakarta.apache.org/commons/fileupload/`。 - 创建一个 `Servlet` 或其他处理上传请求的类,继承自 `FileUploadBase`。 - 初始化 `...

    java结合jsp写的上传文件代码

    import org.apache.commons.fileupload.FileUploadBase.SizeLimitExceededException; import org.apache.commons.fileupload.disk.DiskFileItemFactory; import org.apache.commons.fileupload.servlet....

    Jsp文件上传下载(工具类源码)

    import org.apache.commons.fileupload.FileUploadBase.SizeLimitExceededException; import org.apache.commons.fileupload.disk.DiskFileItemFactory; import org.apache.commons.fileupload.servlet....

    javaweb文件上传/图片上传

    import org.apache.commons.fileupload.FileUploadBase; import org.apache.commons.fileupload.servlet.ServletFileUpload; ... public void doPost(HttpServletRequest request, HttpServletResponse response) ...

    java组件commons-fileupload实现文件上传

    Servlet { /** ...总之,Apache Commons FileUpload简化了Java中的文件上传流程,但开发者仍需关注安全性和性能优化等问题。通过合理配置和恰当的异常处理,可以构建一个稳定、安全的文件上传系统。

Global site tag (gtag.js) - Google Analytics