1

我有一个 Web 应用程序运行在:

  • 野蝇 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="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>

我的豆子:

@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()");
    }
}

网页.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>
4

1 回答 1

1

我对 Wildfly 8.1、PrimeFaces 5.1、漂亮的面孔和文件上传有同样的问题。有一个 HACK 可以在 Tomcat 中完成这项工作,但我找不到它。PrettyFaces 似乎对多部分发布请求做了一些坏事,导致它们无法正常工作......他们似乎将其推回 Undertow/Wildfly,因为 Tomcat 中存在黑客而不是修复实际问题。

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

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

我在这方面遇到了障碍,我无法真正提取 PrettyFaces、PrimeFaces-Fileupload(我需要后台 ajax/html5 上传)或 Wildfly ......任何有“使用 iframe/简单模式”以外的建议的人都会是非常感激。

于 2014-10-24T15:24:36.443 回答