文件上传过滤器的 JSF 配置 [英] JSF Configuration of the file upload filter
问题描述
我正在尝试使用 fileUpload 组件.当我阅读 primefaces 用户指南时,我必须配置 fileUpload 过滤器.
I am trying to use fileUpload component. As I read from primefaces user guide, I have to configure the fileUpload filter.
<filter>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<filter-class>
org.primefaces.webapp.filter.FileUploadFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
我将这些行(由指南建议)添加到 web.xml 文件中.
I added these lines (suggested by the guide) to the web.xml file.
现在,当服务器 (Tomcat 7) 启动时,出现异常并且服务器无法启动.我将发布部分堆栈跟踪.
Now, when the server (Tomcat 7) is starting, I get an exception and the server fails to start. I'll post part of stack trace.
GRAVE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/webApp]]
at java.util.concurrent.FutureTask$Sync.innerGet(Unknown Source)
at...
Caused by: java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory
at....
Caused by: java.lang.ClassNotFoundException: org.apache.commons.fileupload.FileItemFactory
这个过滤器的配置有用吗?如何正确配置?
Is the configuration of this filter useful? How can I configure it properly?
推荐答案
PrimeFaces 用户指南(第 14 页)列出了 p:fileUpload
所需的依赖项:
The PrimeFaces user guide (page 14) lists the required dependencies for p:fileUpload
:
似乎您缺少第一个依赖项.
Seems that you are missing the first dependency.
您可以下载这些文件并将其放入 /WEB-INF/lib
或者 - 如果您的项目是 Maven 项目 - 将以下依赖项添加到您的 pom.xml
>,
部分:
You can either download and place those files into /WEB-INF/lib
or - if your project is a maven project - add the following dependencies to your pom.xml
, <dependencies>
section:
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.2.2</version>
</dependency>
版本可能不同,目前我的 pom.xml 中有这个
这篇关于文件上传过滤器的 JSF 配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!