<p:fileUpload> limiting to 2 Mb

有些话、适合烂在心里 提交于 2020-01-13 06:44:12

问题


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".


回答1:


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")



来源:https://stackoverflow.com/questions/21256767/pfileupload-limiting-to-2-mb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!