springboot⼯程⽂件上传出现net::
ERR_CONNECTION_ABORTED。。。
SpringBoot做⽂件上传时出现了The field file exceeds its maximum permitted size of 1048576 bytes.错误,显⽰⽂件的⼤⼩超出了允许的范围。查看了官⽅⽂档,原来Spring Boot⼯程嵌⼊的tomcat限制了请求的⽂件⼤⼩,这⼀点在Spring Boot的官⽅⽂档中有说明,原⽂如下65.5 Handling Multipart File Uploads
Spring Boot embraces the Servlet 3 javax.servlet.http.Part API to support uploading files. By default Spring Boot configures Spring MVC with a maximum file of 1Mb per file and a maximum of 10Mb of file data in a single request. You may override these values, as well as the location to which intermediate data is stored (e.g., to the /tmp directory) and the threshold past which data is flushed to disk by using the properties exposed in the MultipartProperties class. If you want to specify that files be unlimited, for example, set the multipart.maxFileSize property to -1.The multipart support is helpful when you want to receive multipart encoded file data as a @RequestParam-annotated parameter of type MultipartFile in a Spring MVC controller handler method.
⽂档说明表⽰,每个⽂件的配置最⼤为1Mb,单次请求的⽂件的总数不能⼤于10Mb。要更改这个默认值
需要在配置⽂件(如application.properties)中加⼊两个配置
需要设置以下两个参数
springboot中文
multipart.maxFileSize
multipart.maxRequestSize
Spring Boot 1.3.x或者之前
multipart.maxFileSize=100Mb
multipart.maxRequestSize=1000Mb
Spring Boot 1.4.x或者之后
spring.http.multipart.maxFileSize=100Mb
spring.http.multipart.maxRequestSize=1000Mb

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。