The company assigned me a task to do the second phase development of a project. After taking over from other project teams, the test files are uploaded
Report errors:
org.springframework.web.multipart.MaxUploadSizeExceededException: Maximum upload size of 1048576 bytes exceeded; nested exception is org.apache.commons.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (1429353) exceeds the configured maximum (1048576) at org.springframework.web.multipart.commons.CommonsMultipartResolver.parseRequest(CommonsMultipartResolver.java:162) at org.springframework.web.multipart.commons.CommonsMultipartResolver.resolveMultipart(CommonsMultipartResolver.java:142) at org.springframework.web.servlet.DispatcherServlet.checkMultipart(DispatcherServlet.java:1089) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:928) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:965) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:867) at javax.servlet.http.HttpServlet.service(HttpServlet.java:648) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:841) at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:528) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1099) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1520) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1476) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:748)
The Lspringmvc+fileupload component is used for uploading. Error message: it means that the size of the uploaded file exceeds the maximum limit.
resolvent:
The configuration in applicationContext.xml is as follows:
<!-- SpringMVC Upload files --> <bean id="multipartResolver"> <property name="defaultEncoding" value="UTF-8" /> <!-- Unit is B,10M=10*1024*1024=10485760 Specifies that the total size of the uploaded file cannot exceed 200 KB. Be careful maxUploadSize Property is not limited to a single file, but to the sum of the capacities of all files --> <property name="maxUploadSize" value="10485760" /> </bean>
Limit upload files to a maximum of 10M. The test passed.
If it is a springboot project, how to set the maximum size of the uploaded file?
The configuration is as follows:
In application.properties
#Maximum size of single file spring.http.multipart.maxFileSize=20Mb #Maximum size of all uploaded files spring.http.multipart.maxRequestSize=1000Mb