不要上传超过10mb的primefaces

时间:2014-12-10 16:16:20

标签: jsf file-upload jsf-2 primefaces

我遇到问题而且看起来很简单,但我找不到答案......也许有人可以帮助我? 我正在使用来自primefaces 5.0的fileUpload,我不能上传超过10mb的文件......一个9.9mb的文件工作正常! = O

我需要更改什么来增加此限制?

代码:

<p:fileUpload multiple="false"  cancelLabel="Cancelar" label="Selecionar Brasão..." fileUploadListener="#{back.uploadArquivo}" mode="advanced" dragDropSupport="true" auto="false" 
         fileLimit="1" sizeLimit="51380224"    update="panel_grid_upload_arquivo, :growl" />

backBean:

  public void uploadArquivo(FileUploadEvent event) {
    DocumentoEntity arquivo = new DocumentoEntity();
    try {
        arquivo.setArquivo(IOUtils.toByteArray(event.getFile().getInputstream()));
        arquivo.setNomeArquivo(event.getFile().getFileName());
        arquivo.setNome(event.getFile().getFileName());
        this.arquivo = arquivo;
        exibirMensagemSucesso("Upload feito com sucesso", "O arquivo agora está associado ao documento");
    } catch (IOException e) {
        exibirMensagemErro("Ocorreu algum erro", "Ocorreu algum erro e o upload não pôde ser feito");
        LOGGER.error("Não realizou o upload do arquivo");
        e.printStackTrace();
    }

}

的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>
</filter-mapping>

超过10mb的文件未到达BackBean ... 提前谢谢!

1 个答案:

答案 0 :(得分:3)

几个小时后我发现了这个问题......真的很简单。这是因为Wildfly 8!我需要把max-post-size =&#34; 50485760&#34;在standalone.xml中,现在工作正常。

<server name="default-server">
            <http-listener name="default" socket-binding="http" max-post-size="50485760"/>
            <host name="default-host" alias="localhost">
                <location name="/" handler="welcome-content"/>
                <filter-ref name="server-header"/>
                <filter-ref name="x-powered-by-header"/>
            </host>
        </server>