upload.parseRequest(request)返回commons.fileUpload中的空列表 [英] upload.parseRequest(request) returns empty list in commons.fileUpload

查看:189
本文介绍了upload.parseRequest(request)返回commons.fileUpload中的空列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 org.apache.commons.fileUpload.FileItem 和其他相关类来将文件从本地机器上传到服务器(尽管目前的测试都是这两台机器都是相同)。

I am using org.apache.commons.fileUpload.FileItem and other related classes for uploading files from local machine to server (Although for the current testing both the machines are same).

我有 .jsp 文件作为UI和servlet来处理上传。现在当请求达到
语句

I am having .jsp file as UI and servlet to handle the upload. Now when the request reaches statement

List items = upload.parseRequest(request);

它返回空列表。我在很多地方用Google搜索了这个东西。其中大多数都指定了 parserequest()返回空的症状。但无法找到避免这种情况的确切解决方案。在一个地方,我可以看到Tomcat可能有过滤器可能已经解析了请求,这就是为什么在上面调用parseRequest返回空列表。但是没有规范如何避免这种情况。

it returns empty list. I googled this thing at many places. Most of them specifying the symptons that parserequest() returns empty. But Could not find out the exact solution to avoid this. At one place I could see that Tomcat may have filters that may have parsed The request and thats why at above call to parseRequest returns empty list. But there is no specification how to avoid this.

是否因为我使用的网络服务器(JBOss)?或者它与java版本和commons.jar版本冲突有什么关系?

Is it because of the web server I am using (which is JBOss) ? or has it anything to do with the java version and commons.jar version conflicts ?

我正在使用


  • jre 1.6

  • jboss-4.0.4.CR2

  • commons-fileupload-1.2.2.jar

  • Eclipse(创建动态Web项目)

  • jre 1.6
  • jboss-4.0.4.CR2
  • commons-fileupload-1.2.2.jar
  • Eclipse (To create dynamic web project)

您的帮助将非常有用。

推荐答案

我在Tomcat中遇到了类似设置的同样问题。解决方案就像在我的输入文件元素上放置一个name属性一样简单。

I encountered this same problem with a similar setup in Tomcat. The solution was as simple as placing a name attribute on my input file element.

在我有< input type =file/>之前; 在我的HTML表单中。

Before I had <input type="file" /> in my HTML form.

一旦我添加了名称标签,即< input type =filename =aFile/> 当我从servlet / JSP调用parseRequest(request)时,我的DiskFileUpload对象停止返回一个空列表。

Once I added a name tag i.e. <input type="file" name="aFile" /> my DiskFileUpload object stopped returning an empty list when I called parseRequest(request) from the servlet/JSP.

这篇关于upload.parseRequest(request)返回commons.fileUpload中的空列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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