用javaee maven上传文件的最佳方法是什么?

时间:2017-04-01 15:53:45

标签: maven java-ee

我试图用fileUpload上传文件,我添加了jar库(commons-io-1.4.jar commons-fileupload-1.2.jar)并通过添加过滤器来配置web.xml:

    <filter>
    <filter-name>PrimeFaces FileUpload Filter</filter-name>
    <filterclass>org.primefaces.webapp.filter.FileUploadFilter</filterclass>
    <init-param>
        <param-name>thresholdSize</param-name>
        <param-value>2097152</param-value>
    </init-param>      
</filter>
<filter-mapping>
    <filter-name>PrimeFaces FileUpload Filter</filter-name>
    <servlet-name>Faces Servlet</servlet-name>
</filter-mapping>     

但是我的构建失败了,我是做对了还是我错过了其他的东西

1 个答案:

答案 0 :(得分:0)

我认为您的代码遇到了依赖性错误。您需要添加版本依赖性

<dependency>
         <groupId>org.apache.commons</groupId>
         <artifactId>commons-io</artifactId>
         <version>2.4</version>
</dependency>
<dependency>
       <groupId>commons-fileupload</groupId>
       <artifactId>commons-fileupload</artifactId>
       <version>1.3.1</version>
 </dependency>