请求大于10485760时连接终止

时间:2018-04-26 15:12:34

标签: spring-boot jhipster

我正在尝试将6MB文件上传到我的JHipster应用服务器。但是,我收到以下错误。我在哪里可以找到相关的配置?

io.undertow.server.RequestTooBigException: UT000020: Connection terminated as request was larger than 10485760
at io.undertow.conduits.FixedLengthStreamSourceConduit.checkMaxSize(FixedLengthStreamSourceConduit.java:168)
at io.undertow.conduits.FixedLengthStreamSourceConduit.read(FixedLengthStreamSourceConduit.java:229)
at org.xnio.conduits.ConduitStreamSourceChannel.read(ConduitStreamSourceChannel.java:127)
at io.undertow.channels.DetachableStreamSourceChannel.read(DetachableStreamSourceChannel.java:209)
at io.undertow.server.HttpServerExchange$ReadDispatchChannel.read(HttpServerExchange.java:2332)
at org.xnio.channels.Channels.readBlocking(Channels.java:294)
at io.undertow.servlet.spec.ServletInputStreamImpl.readIntoBuffer(ServletInputStreamImpl.java:192)
at io.undertow.servlet.spec.ServletInputStreamImpl.read(ServletInputStreamImpl.java:168)
at io.undertow.server.handlers.form.MultiPartParserDefinition$MultiPartUploadHandler.parseBlocking(MultiPartParserDefinition.java:213)
at io.undertow.servlet.spec.HttpServletRequestImpl.parseFormData(HttpServletRequestImpl.java:792)

4 个答案:

答案 0 :(得分:4)

Spring Boot具有以下默认属性

spring.servlet.multipart.max-file-size=1MB # Max file size. Values can use the suffixes "MB" or "KB" to indicate megabytes or kilobytes, respectively.
spring.servlet.multipart.max-request-size=10MB # Max request size. Values can use the suffixes "MB" or "KB" to indicate megabytes or kilobytes, respectively.

10485760 = 10MB

查看文件上传Spring Boot guide

答案 1 :(得分:2)

对于Spring Boot 1.5.13.RELEASE,请尝试以下属性:

spring.http.multipart.max-request-size=100MB
spring.http.multipart.max-file-size=100MB

答案 2 :(得分:0)

在容器级别,可以直接在连接器上指定属性maxPostSize

来自docs:

  

POST的最大字节数,将由容器FORM URL参数解析处理。可以通过将此属性设置为小于或等于0的值来禁用该限制。如果未指定,则此属性设置为2097152(2兆字节)。

答案 3 :(得分:0)

除了maslbl4答案外,对于像我这样使用“ .yml”配置文件的用户,请使用以下代码:

spring:
  servlet:
    multipart:
      max-file-size: 100MB
      max-request-size: 100MB

对我来说很好。