我有一个相当简单的 Spring Boot Web 应用程序,我有一个带有 enctype="multipart/form-data"
的表单的 HTML 页面。我收到此错误:
The multi-part request contained parameter data (excluding uploaded files) that exceeded the limit for maxPostSize set on the associated connector.
我正在使用 Spring Boot 的默认嵌入式 tomcat 服务器。显然,默认的 maxPostSize
值是 2 兆字节。有没有办法编辑这个值?通过 application.properties
这样做是最好的,而不必创建自定义 bean 或弄乱 xml 文件。
最佳答案
在 application.properties 文件中写下:
# Max file size.
spring.http.multipart.max-file-size=1Mb
# Max request size.
spring.http.multipart.max-request-size=10Mb
根据需要调整大小。
更新
注意:从 Spring Boot 2 开始,您现在可以这样做
# Max file size.
spring.servlet.multipart.max-file-size=1MB
# Max request size.
spring.servlet.multipart.max-request-size=10MB
关于java - 在 Spring Boot 中增加 HTTP Post maxPostSize,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33232849/