文件上传不适用于PrimeFaces 4.0,JSF Mojarra 2.2.3和Wildfly Beta 1 [英] File upload doesn't work with PrimeFaces 4.0, JSF Mojarra 2.2.3 and Wildfly Beta 1

查看:122
本文介绍了文件上传不适用于PrimeFaces 4.0,JSF Mojarra 2.2.3和Wildfly Beta 1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个web应用程序运行于:


  • Wildfly Beta 1

  • JSF Mojarra 2.2 .3(来自Wildfly)

  • Primefaces 4.0

  • rewrite-servlet-2.0.7.Final / rewrite-config-prettyfaces-2.0.7。 Final

  • commons-io-2.4 / commons-fileupload-1.3



与文件上传组件(高级和简单的模式不起作用,从不打印 里面upload() )。

相同甚至没有rewrite-servlet-2.0.7.Final/rewrite-config-prettyfaces-2.0.7.Final库。



我的upload.xhtml文件:



< h:form prependId =falseid =formLateralUploadenctype =multipart / form-data>
< h:panelGrid columns =1cellpadding =5>
fileUploadListener =#{test.upload}auto =truesizeLimit = 10500000\" />
< / h:panelGrid>
< / h:表格>

我的bean:

@ManagedBean(name =test)
@ViewScoped
public class Test {
private UploadedFile文件;

public UploadedFile getFile(){
return file;
}

public void setFile(UploadedFile file){
this.file = file;
}

public void upload(FileUploadEvent event){
System.out.println(inside upload());


code
$ b

web.xml:



 <?xml version =1.0encoding =UTF-8?> ; 
< web-app
xmlns:xsi =http://www.w3.org/2001/XMLSchema-instance
xmlns =http://xmlns.jcp.org / xml / ns / javaee
xsi:schemaLocation =http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1 .xsd
id =test
version =3.1>
< display-name> test< / display-name>
< welcome-file-list>
< welcome-file> /< / welcome-file>
< / welcome-file-list>

< 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>
< dispatcher>请求< /调度器>
< dispatcher> FORWARD< / dispatcher>
< / filter-mapping>

< servlet>
< servlet-name> Faces Servlet< / servlet-name>
< servlet-class> javax.faces.webapp.FacesServlet< / servlet-class>
<加载启动> 1< /加载启动>
< / servlet>
< servlet-mapping>
< servlet-name> Faces Servlet< / servlet-name>
< url-pattern> / faces / *< / url-pattern>
< url-pattern> *。xhtml< / url-pattern>
< / servlet-mapping>

< context-param>
< param-name> javax.faces.PARTIAL_STATE_SAVING< / param-name>
< param-value> true< /参数值>
< / context-param>

<错误页面>
< / exception-type> javax.faces.application.ViewExpiredException< / exception-type>
< location> / redirect< / location>
< / error-page>
< / web-app>


解决方案

我有和Wildfly 8.1,PrimeFaces 5.1 ,漂亮的面孔和文件上传。在Tomcat中有一个HACK来完成这个工作,但是我找不到一个。 PrettyFaces似乎正在做一些不好的事情多部分发布请求,以防止他们正常工作...他们似乎推回到Undertow / Wild,因为黑客存在于Tomcat而不是修复实际问题。

Wild Discussion讨论: http: //ocpsoft.org/support/topic/pretty-primefaces-fileupload/



Tomcat Hack: http://ocpsoft.org/support/topic/split-prettyfaces-anchor-with- primefaces-file-upload-not-working /

我在这个道路上被挡住了,我不能提取PrettyFaces,PrimeFaces-Fileupload(我需要背景ajax / html5上传)或Wild ... ...任何人建议,而不是使用iframe /简单模式将不胜感激。

I have a web application running on:

  • Wildfly Beta 1
  • JSF Mojarra 2.2.3 (from Wildfly)
  • Primefaces 4.0
  • rewrite-servlet-2.0.7.Final / rewrite-config-prettyfaces-2.0.7.Final
  • commons-io-2.4 / commons-fileupload-1.3

And I have problem with file upload component (advanced and simple mode doesn't work, never print inside upload()).

Same is even run without rewrite-servlet-2.0.7.Final/rewrite-config-prettyfaces-2.0.7.Final libs.

My upload.xhtml file:

<h:form prependId="false" id="formLateralUpload" enctype="multipart/form-data">
    <h:panelGrid columns="1" cellpadding="5">
        <p:fileUpload mode="advanced" multiple="true" update="@widgetVar(msg)"
            fileUploadListener="#{test.upload}" auto="true" sizeLimit="10500000"/>
    </h:panelGrid>
</h:form>

My bean:

@ManagedBean(name = "test")
@ViewScoped
public class Test {
    private UploadedFile      file;

    public UploadedFile getFile() {
        return file;
    }

    public void setFile(UploadedFile file) {
        this.file = file;
    }

    public void upload(FileUploadEvent event) {
        System.out.println("inside upload()");
    }
}

web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
    id="test"
    version="3.1">
    <display-name>test</display-name>
    <welcome-file-list>
        <welcome-file>/</welcome-file>
    </welcome-file-list>

     <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>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>FORWARD</dispatcher>
    </filter-mapping>

    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
        <url-pattern>*.xhtml</url-pattern>
    </servlet-mapping>

    <context-param>
        <param-name>javax.faces.PARTIAL_STATE_SAVING</param-name>
        <param-value>true</param-value>
    </context-param>

    <error-page>
        <exception-type>javax.faces.application.ViewExpiredException</exception-type>
        <location>/redirect</location>
    </error-page>
</web-app>

解决方案

I have the same issue with Wildfly 8.1, PrimeFaces 5.1, Pretty faces and file upload. There is a HACK to make this work in Tomcat, but I can't find one in undertow. PrettyFaces appears to be doing something bad to multipart post requests that prevents them from working correctly... They seem to be pushing it back to Undertow/Wildfly because the hack exists in Tomcat instead of fixing the actual issue.

Wildfly Discussion: http://ocpsoft.org/support/topic/pretty-primefaces-fileupload/

Tomcat Hack: http://ocpsoft.org/support/topic/split-prettyfaces-anchor-with-primefaces-file-upload-not-working/

I'm road blocked on this and I can't really extract either PrettyFaces, PrimeFaces-Fileupload (I need background ajax/html5 uploading) or Wildfly... Anyone with a suggestion other than "use an iframe/simple mode" would be much appreciated.

这篇关于文件上传不适用于PrimeFaces 4.0,JSF Mojarra 2.2.3和Wildfly Beta 1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆