我使用SPring启动来开发我的系统,但是在上传超过1MB的文件时使用此异常(使用多部分文件类型)。有谁可以向我解释一下?谢谢
java.lang.IllegalStateException:Multipart Mime零件文件超出了org.eclipse.jetty.util.MultiPartInputStreamParser $ MultiPart.write(MultiPartInputStreamParser.java:111)〜[jetty-util-9.2.14.v20151106.jar:9.2。 14.v20151106]在org.eclipse.jetty的org.eclipse.jetty.util.MultiPartInputStreamParser.parse(MultiPartInputStreamParser.java:681)〜[jetty-util-9.2.14.v20151106.jar:9.2.14.v20151106]。 util.MultiPartInputStreamParser.getParts(MultiPartInputStreamParser.java:400)〜[jetty-util-9.2.14.v20151106.jar:9.2.14.v20151106] at org.eclipse.jetty.server.Request.getParts(Request.java:2146 )〜[jetty-server-9.2.14.v20151106.jar:9.2.14.v20151106] org.eclipse.jetty.server.Request.extractMultipartParameters(Request.java:386)〜[jetty-server-9.2.14。 v20151106.jar:9.2.14.v20151106] org.eclipse.jetty.server.Request.extractContentParameters(Request.java:309)〜[jetty-server-9.2.14.v20151106.jar:9.2.14.v20151106] at at org.eclipse.jetty.server.Request.extractParameters(Request.java:257)~ [jett y-server-9.2.14.v20151106.jar:9.2.14.v20151106] at org.eclipse.jetty.server.Request.getParameter(Request.java:826)~ [jetty-server-9.2.14.v20151106.jar :9.2.14.v20151106] org.springframework上的org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:70)〜[spring-web-4.2.4.RELEASE.jar:4.2.4.RELEASE] org.eclipse.jetty.servlet.ServletHandler $ CachedChain.doFilter中的.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)〜[spring-web-4.2.4.RELEASE.jar:4.2.4.RELEASE] ServletHandler.java:1652)~ [jetty-servlet-9.2.14.v20151106.jar:9.2.14.v20151106] org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121)~ [spring-web -4.2.4.RELEASE.jar:4.2.4.RELEASE]在org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)〜[spring-web-4.2.4.RELEASE.jar:4.2。 4.RELEASE]在org.eclipse.jetty.servlet.ServletHandler $ CachedChain.doFilter(ServletHandler.java:1652)〜[jet ty-servlet-9.2.14.v20151106.jar:9.2.14.v20151106] at org.springframework.boot.actuate.autoconfigure.MetricsFilter.doFilterInternal(MetricsFilter.java:103)〜[spring-boot-actuator-1.3.1 .RELEASE.jar:1.3.1.RELEASE]在org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)〜[spring-web-4.2.4.RELEASE.jar:4.2.4.RELEASE]在orn.eclipse.jetty.servlet.ServletHandler $ CachedChain.doFilter(ServletHandler.java:1652)〜[jetty-servlet-9.2.14.v20151106.jar:9.2.14.v20151106] at vn.com.splussoftware.sms。 config.OAuth2AuthenticationFilter.doFilter(OAuth2AuthenticationFilter.java:71)〜[bin /:na] at org.eclipse.jetty.servlet.ServletHandler $ CachedChain.doFilter(ServletHandler.java:1652)~ [jetty-servlet-9.2.14。 v20151106.jar:9.2.14.v20151106] org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585)[jetty-servlet-9.2.14.v20151106.jar:9.2.14.v20151106] at org .eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)[jetty-server-9.2.14.v201 51106.jar:9.2.14.v20151106] org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577)[jetty-security-9.2.14.v20151106.jar:9.2.14.v20151106] at org .eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)[jetty-server-9.2.14.v20151106.jar:9.2.14.v20151106] org.eclipse.jetty.server.handler.ContextHandler .doHandle(ContextHandler.java:1127)[jetty-server-9.2.14.v20151106.jar:9.2.14.v20151106] org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)[jetty- servlet-9.2.14.v20151106.jar:9.2.14.v20151106] at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)[jetty-server-9.2.14.v20151106.jar: 9.2.14.v20151106]在org.eclipse的org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)[jetty-server-9.2.14.v20151106.jar:9.2.14.v20151106] orjet.eclipse.jetty中的.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)[jetty-server-9.2.14.v20151106.jar:9.2.14.v20151106]。 server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)[jetty-server-9.2.14.v20151106.jar:9.2.14.v20151106] org.eclipse.jetty.server.Server.handle(Server.java: 499)[jetty-server-9.2.14.v20151106.jar:9.2.14.v20151106] org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311)[jetty-server-9.2.14.v20151106 .jar:9.2.14.v20151106] org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)[jetty-server-9.2.14.v20151106.jar:9.2.14.v20151106] at org。 eclipse.jetty.io.AbstractConnection $ 2.run(AbstractConnection.java:544)[jetty-io-9.2.14.v20151106.jar:9.2.14.v20151106] org.eclipse.jetty.util.thread.QueuedThreadPool.runJob (QueuedThreadPool.java:635)[jetty-util-9.2.14.v20151106.jar:9.2.14.v20151106] org.eclipse.jetty.util.thread.QueuedThreadPool $ 3.run(QueuedThreadPool.java:555)[码头-util-9.2.14.v20151106.jar:9.2.14.v20151106] at java.lang.Thread.run(Unknown Source)[na:1.8.0_66]
在application.properties
文件中配置文件上载
确定限制
例如在这个地方3Mb
multipart.maxFileSize: 3Mb
multipart.maxRequestSize: 3Mb
你也可以配置自己的尺寸
在属性文件中,事情发生了一些变化。
spring:
http:
multipart:
maxFileSize: 20MB
maxRequestSize: 20MB
在节点<servlet> .... <multipart-config>
<location>/tmp</location>
<max-file-size>1000000000</max-file-size>
<max-request-size>1500000000</max-request-size>
<file-size-threshold>0</file-size-threshold>
</multipart-config>
对于Spring Boot 2,application.yml
文件将如下所示:
spring:
servlet:
multipart:
enabled: true
max-file-size: 20MB
max-request-size: 20MB
在春天的文件(https://spring.io/guides/gs/uploading-files/)建议放入src/main/resources/application.properties
:
spring.servlet.multipart.max-file-size=100Mb
spring.servlet.multipart.max-request-size=100Mb
对我有用!
不对文件大小和请求大小添加任何限制
Spring Boot 1.5.x:
spring.http.multipart.max-file-size=-1
spring.http.multipart.max-request-size=-1
Spring Boot 2.0.x:
spring.servlet.multipart.max-file-size=-1
spring.servlet.multipart.max-request-size=-1