p:fileupload 在 Websphere 8 上不起作用

发布于 2024-12-13 13:56:39 字数 2194 浏览 3 评论 0原文

我想知道是否有人设法让 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)

I wonder if anyone managed to get Primefaces' p:fileupload component work on Websphere Application Server 8.

I use Primefaces 2.2.1 version.

JSF code:

<h:form enctype="multipart/form-data">  
    <p:fileUpload 
            fileUploadListener="#{mailBean.handleFileUpload}"   
            multiple="true" 
            label="choose" 
            allowTypes="*.jpg;*.png;*.gif;" 
            description="Images"/>          
</h:form>

Managed Bean code:

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 filter: (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>

The component says HTTP error and turns into red, on the console I get a ViewExpiredException by Myfaces:

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)

I even tried with two other versions of Mojarra instead of Myfaces, but I got errors (2.1: handler doesnt get invoked, 2.0.3: viewexpired)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

樱花落人离去 2024-12-20 13:56:39

你有 .jars 和 web.xml 配置吗(删除“c:”,默认是该路由)?我遇到了同样的问题,但后来我重新启动了 WAS 8.5,它就工作了。

Did u have the .jars and the web.xml config (remove "c:", the default is that route) ? I had the same problem but then i restarted my WAS 8.5 and it worked.

寄人书 2024-12-20 13:56:39

我将 Websphere 7 与 JSF 2.0 以及 Mojarra 2 和 PrimeFaces 3.4.2(common-fileupload-1.2.2.jar 和 common-io-1.3.2.jar)一起使用,

我看到 fileUpload 没有调用 WebSphere 中的 bean 。
我看到加载文件的栏,但没有到达 ManagedBean 上的事件。

似乎 Websphere 中的其他过滤器捕获了 HTTP 请求,并且您无法获取 fileUpload 发送的数据,因为它们只是被消耗了:(

I'm using Websphere 7 with JSF 2.0 with Mojarra 2 and PrimeFaces 3.4.2 (common-fileupload-1.2.2.jar and common-io-1.3.2.jar)

I see the fileUpload don't call the bean in WebSphere.
I see the bar that load the file but don't arrive the event on the managedBean.

It seems as if some other filter in Websphere capture the HTTP request and you can't get data sent by fileUpload because are just consumed :(

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文