FileUpload:找不到DeferredFileOutputStream类? [英] FileUpload: DeferredFileOutputStream class not found?

查看:513
本文介绍了FileUpload:找不到DeferredFileOutputStream类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用apache FileUpload来处理..文件上传。我在码头上用它。 servlet看到multipart请求,但在执行时抛出NoClassDefFoundError异常:

I'm using apache FileUpload to handle a.. file upload. I'm using it with jetty. The servlet sees the multipart request, but throws a NoClassDefFoundError exception upon execution:

protected void doPost(HttpServletRequest request, HttpServletResponse response) 
  throws ServletException, IOException 
{
  boolean isMultipart = ServletFileUpload.isMultipartContent(req);
  if (isMultipart) {
    try {
      FileItemFactory factory = new DiskFileItemFactory();

      ServletFileUpload upload = new ServletFileUpload(factory);

      List items = upload.parseRequest(req); //  exception
      ...

抛出:

java.lang.NoClassDefFoundError: org/apache/commons/io/output/DeferredFileOutputStream
   at org.apache.commons.fileupload.disk.DiskFileItemFactory.createItem(DiskFileItemFactory.java:199)

由以下原因引起:

java.lang.ClassNotFoundException: org.apache.commons.io.output.DeferredFileOutputStream

除了commons-fileupload-1.2.2.jar还需要包含额外的jar吗?

Is there an additional jar we need to include besides commons-fileupload-1.2.2.jar?

我的目标是上传单个文件并将其写入磁盘。

My goal is to just upload a single file and write it to disk.

谢谢

推荐答案

您需要将 CommonsIO 添加到类路径中。 Commons File Upload取决于它。

You need to add CommonsIO to the classpath. Commons File Upload is dependent on it.

这篇关于FileUpload:找不到DeferredFileOutputStream类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆