<号码:文件上传>限制到2 Mb [英] <p:fileUpload> limiting to 2 Mb

查看:118
本文介绍了<号码:文件上传>限制到2 Mb的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了 fileUpload 的问题。当文件大于2 MB时,它不会触发 fileUploadListener 组件:

 < p:fileUpload id =uploadrequired =true
fileUploadListener =#{myBean.handleFileUpload}
fileLimit =1
requiredMessage =需要文件
fileLimitMessage =仅一个文件
invalidFileMessage =无效文件
cancelLabel =取消label = 选择
allowTypes =/(\。| \ /)(gif | jpe?g | png)$ //>

环境:JSF 2.2.3,Primefaces 4.0,Tomcat 7



可能是一些过滤器配置问题?

@EDIT:更多信息。与 mode =simple

解决方案

默认最大POST大小为2MB,可在 HTTP < Connector> 配置 /conf/server.xml 中。以下是文档的摘录:


maxPostSize



最大字节数的POST将由容器FORM URL参数解析处理。如果未指定此属性,则将此属性设置为2097152(2兆字节)。



可以通过将此属性设置为小于或等于0的值来禁用限制。

因此,如果您想禁用它,请这样做:

 < Connector ... maxPostSize =  -  1 > 

0 -1 更自我记录为允许每个尺寸)

I'm having some issues with fileUpload. It's not firing the fileUploadListener when the file is > 2 Mb.

The component:

<p:fileUpload id="upload" required="true"
fileUploadListener="#{myBean.handleFileUpload}"
fileLimit="1"
requiredMessage="A file is required"
fileLimitMessage="One file only"
invalidFileMessage="Invalid file"
cancelLabel="Cancel" label="Choose"
allowTypes="/(\.|\/)(gif|jpe?g|png)$/" />

Enviroment: JSF 2.2.3, Primefaces 4.0, Tomcat 7

Might it be some "filter" configuration problem?

@EDIT: More info. Same problem with mode="simple".

解决方案

Tomcat has a default maximum POST size of 2MB which is configurable in the HTTP <Connector> configuration in its /conf/server.xml. Here's an extract from the documentation:

maxPostSize

The maximum size in bytes of the POST which will be handled by the container FORM URL parameter parsing. The limit can be disabled by setting this attribute to a value less than or equal to 0. If not specified, this attribute is set to 2097152 (2 megabytes).

Thus, if you want to disable it, do so:

<Connector ... maxPostSize="-1">

(0 can also, but the -1 is more self-documenting as to "allow every size")

这篇关于&LT;号码:文件上传&GT;限制到2 Mb的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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