Primefaces事件.getFile().getContents()为空

Primefaces事件.getFile().getContents()为空,primefaces,Primefaces,我在项目文件上载事件中使用PrimeFaces 5.1,以使内容为空 web.xml <filter> <filter-name>PrimeFaces FileUpload Filter</filter-name> <filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class> </filter> <filter-mapping>

我在项目文件上载事件中使用PrimeFaces 5.1,以使内容为空

web.xml

<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>
<p:fileUpload id="leftFileUploadId" 
fileUploadListener="#{user.ImageButton}" mode="advanced"  
allowTypes="/(\.|\/)(jpe?g|png)$/i" fileLimit="1" update="mainPanel">
</p:fileUpload>
结果

Event getFile : org.primefaces.model.NativeUploadedFile@35f44253
File Name : 1.jpg
Content Type :image/jpeg
Fiel upload contents : null

我的疑问是为什么event.getFile().getContents()为空。

我在5.1中也遇到了同样的问题。 在查看NativeUploadedFile的源代码后,我看到: 版本5.1

public byte[] getContents() {
    return null;
}
版本5.2

public byte[] getContents() {
    if (cachedContent != null) {
        return cachedContent;
    }

    InputStream input = null;
    try {
        input = getInputstream();
        ByteArrayOutputStream output = new ByteArrayOutputStream();
        byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];

        int n = 0;
        while (-1 != (n = input.read(buffer))) {
            output.write(buffer, 0, n);
        }
        cachedContent = output.toByteArray();
    }
    catch (IOException ex) {
        cachedContent = null;
        throw new FacesException(ex);
    }
    finally {
        if (input != null) {
            try {
                input.close();
            }
            catch (IOException ex) {
            }
        }
    }

    return cachedContent;
}

换句话说,使用5.2或更高版本。我不知道为什么会有这种变化

调试代码?
public byte[] getContents() {
    if (cachedContent != null) {
        return cachedContent;
    }

    InputStream input = null;
    try {
        input = getInputstream();
        ByteArrayOutputStream output = new ByteArrayOutputStream();
        byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];

        int n = 0;
        while (-1 != (n = input.read(buffer))) {
            output.write(buffer, 0, n);
        }
        cachedContent = output.toByteArray();
    }
    catch (IOException ex) {
        cachedContent = null;
        throw new FacesException(ex);
    }
    finally {
        if (input != null) {
            try {
                input.close();
            }
            catch (IOException ex) {
            }
        }
    }

    return cachedContent;
}