我想知道是否有人设法让Primefaces的p:fileupload
组件在Websphere Application Server 8上运行。
我使用的是Primefaces 2.2.1版本。
JSF代码:
<h:form enctype="multipart/form-data">
<p:fileUpload
fileUploadListener="#{mailBean.handleFileUpload}"
multiple="true"
label="choose"
allowTypes="*.jpg;*.png;*.gif;"
description="Images"/>
</h:form>
托管Bean代码:
public void handleFileUpload(FileUploadEvent event)
{
files.add(event.getFile());
logger.info("File uploaded into MailBean: " + event.getFile());
System.out.println("File uploaded into MailBean: " + event.getFile());
}
Web.xml过滤器:(Servlet 3.0)
<filter>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
<init-param>
<param-name>thresholdSize</param-name>
<param-value>51200</param-value>
</init-param>
<init-param>
<param-name>uploadDirectory</param-name>
<param-value>c:/temp/pf</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
组件说HTTP错误并变为红色,在控制台上我得到Myfaces的ViewExpiredException:
Caused by: javax.faces.application.ViewExpiredException: /createmail.xhtml
No saved view state could be found for the view identifier: /createmail.xhtml
at org.apache.myfaces.lifecycle.RestoreViewExecutor.execute(RestoreViewExecutor.java:128)
at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:171)
at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:189)
我甚至尝试过使用其他两个版本的Mojarra而不是Myfaces,但是我遇到了错误(2.1:处理程序没有被调用,2.0.3:viewexpired)
答案 0 :(得分:0)
您是否拥有.jars和web.xml配置(删除“c:”,默认是该路由)?我有同样的问题,但后来我重新启动我的WAS 8.5,它的工作原理。
答案 1 :(得分:0)
我正在使用带有Mofarra 2和PrimeFaces 3.4.2的JSF 2.0的Websphere 7(common-fileupload-1.2.2.jar和common-io-1.3.2.jar)
我看到fileUpload不会在WebSphere中调用bean。 我看到加载文件的栏,但没有到达managedBean上的事件。
似乎Websphere中的某个其他过滤器捕获了HTTP请求,并且您无法获取fileUpload发送的数据,因为它们刚被消耗:(