I've got a fairly simple Spring Boot web application, I have a single HTML page with a form with enctype="multipart/form-data"
. I'm getting this error:
The multi-part request contained parameter data (excluding uploaded files) that exceeded the limit for maxPostSize set on the associated connector.
I'm using Spring Boot's default embedded tomcat server. Apparently the default maxPostSize
value is 2 megabytes. Is there any way to edit this value? Doing so via application.properties
would be best, rather than having to create customized beans or mess with xml files.
Apply settings for Tomcat as well as servlet
You can set the max post size for Tomcat in
application.properties
which is set with an int as below. Just settingspring.servlet.multipart.max-request-size=10MB
, as in some other answers, may not be enough.Working with Spring Boot
2.0.5.RELEASE
This worked for me with Tomcat 8
from documentation: https://spring.io/guides/gs/uploading-files/
None of the solutions did work for me and most of them are just downright offtopic because OP is talking about maxPostSize, and not maxFileSize (latter gives you a different error anyway if the size is exceeded)
Solution: in /tomcat/conf/server.xml add maxPostSize="" attribute to Connector