【问题标题】:Stripes Framework file upload using apache fileuploadStripes 框架文件上传使用 apache fileupload
【发布时间】:2015-07-04 06:43:59
【问题描述】:

我一直在尝试将 ck 编辑器文件上传与使用 Stripes 1.8 开发的应用程序集成,但未能成功。 从 CK editor file bowser (plain html) ,我可以点击一个处理文件上传功能的 servlet。但是下面这段代码执行失败。

// get uploaded file list
// the following code uses commons-fileupload-1.3.1
// the imports are removed for crispiness of the code
FileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
if (ServletFileUpload.isMultipartContent(request)) {
   try {
      List files = upload.parseRequest(request); // returns an empty list
   }catch (Exception e) { // no error handling}
      e.printStackTrace();
   }
}

可能是什么原因,是否有某种解决方法。 顺便说一句,相同的代码在 Struts 1.3 应用程序中运行良好。

【问题讨论】:

    标签: java file-upload stripes


    【解决方案1】:

    问题出在 web.xml 设置上

    <filter-mapping>
        <filter-name>stripesFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    

    什么时候改成

    <filter-mapping>
        <filter-name>stripesFilter</filter-name>
        <url-pattern>/action/*</url-pattern>
    </filter-mapping>
    

    请求已经被解析,因为它通过了条带 servlet 过滤器。由于输入流已被该早期进程使用,因此不再可用于 Commons FileUpload 解析。

    【讨论】:

      猜你喜欢
      • 2012-02-28
      • 2015-12-23
      • 2014-02-20
      • 1970-01-01
      • 1970-01-01
      • 2015-07-09
      • 2018-01-31
      • 2013-08-17
      • 1970-01-01
      相关资源
      最近更新 更多