18
4
|
I've got a fairly simple Spring Boot web application, I have a single HTML page with a form with
I'm using Spring Boot's default embedded tomcat server. Apparently the default |
||||||||||||
|
10
|
In application.properties file write this:
adjust size according to your need. |
||||||||||||||||
|
9
|
Found a solution. Add this code to the same class running SpringApplication.run.
Edit: Apparently adding this to your application.properties file will also increase the maxPostSize, but I haven't tried it myself so I can't confirm.
|
||||||||
|
3
|
There is some difference when we define the properties in the application.properties and application yaml. In application.yml :
And in application.propeties : spring.http.multipart.max-file-size=128KB spring.http.multipart.max-request-size=128KB Note : Spring version 4.3 and Spring boot 1.4 |
||
2
|
from documentation: https://spring.io/guides/gs/uploading-files/
|
https://stackoverflow.com/questions/33232849/increase-http-post-maxpostsize-in-spring-boot
其它参考:
http://godjohnny.iteye.com/blog/2352626
http://www.91r.net/ask/33232849.html
这种方式是根据spring boot的EmbeddedServletContainerCustomizer 内嵌tomcat配置实现的
connector.setMaxPostSize(10000000); // 10 MB
,我的程序编译成war包,使用外部tomcat的,所以无法注入
顺便提一下:
spring.http.multipart.max-file-size=100Mb spring.http.multipart.max-request-size=1000Mb框架层面(非tomcat层面)在springboot下并没有什么用,springboot中起控制作用的是:
multipart.maxFileSize=100Mb multipart.maxRequestSize=1000Mbhttp://blog.csdn.net/silyvin/article/details/70665377
那么然后自然就想到直接改tomcat的maxpostsize参数,但是动作太大,姑且把这种方法搁置
分析一下情况,tomcat默认2M的maxPostSize,h5 ajax一直可以正常使用,安卓也可以,为什么?
查到:maxPostSize参数只有当request的Content-Type为“application/x-www-form-urlencoded”时起作用。
参考:http://blog.csdn.net/lafengwnagzi/article/details/72846195
As can be seen in Request.java, maxPostSize is taken into account only for the "application/x-www-form-urlencoded" content type and is not affected by how the request is made ("normal" vs. xhr).
https://stackoverflow.com/questions/7696197/tomcat-maxpostsize-value-ignored-with-xmlhttprequest
于是我找到h5
使用
安卓也显式设置 maltipart/form-data,
猜测ios的网络库可能作了些调整
于是找到ios,调试下来发现也是 maltipart/form-data,算了直接修改tomcat 的 maxPostSize吧(默认2M,修改为-1即可,tomcat8之后,0不行了),就这样了
ios使用的网络库为anf