寫入的響應頭的資料超出緩Increase maxHttpHeaderSize on the connector or write less data into the response headers
阿新 • • 發佈:2019-01-08
最近寫了帶有檔案上傳的專案遇到的坑
報錯問題:
嚴重: Servlet.service() for servlet [springServlet] in context with path [] threw exception [Request processing failed; nested exception is org.apache.coyote.http11.HeadersTooLargeException: An attempt was made to write more data to the response headers than there was room available in the buffer.
org.apache.coyote.http11.HeadersTooLargeException: An attempt was made to write more data to the response headers than there was room available in the buffer. Increase maxHttpHeaderSize on the connector or write less data into the response headers.
at org.apache.coyote.http11.AbstractOutputBuffer.checkLengthBeforeWrite(AbstractOutputBuffer.java:547)
at org.apache.coyote.http11.AbstractOutputBuffer.write(AbstractOutputBuffer.java:511)
at org.apache.coyote.http11.AbstractOutputBuffer.write(AbstractOutputBuffer.java:428)
at org.apache.coyote.http11.AbstractOutputBuffer.sendHeader(AbstractOutputBuffer.java:394)
at org.apache.coyote.http11.AbstractHttp11Processor.prepareResponse(AbstractHttp11Processor.java:1540)
at org.apache.coyote.http11.AbstractHttp11Processor.action(AbstractHttp11Processor.java:773)
at org.apache.coyote.Response.action(Response.java:174)
at org.apache.coyote.Response.sendHeaders(Response.java:365)
at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:352)
at org.apache.catalina.connector.OutputBuffer.flush(OutputBuffer.java:333)
at org.apache.catalina.connector.CoyoteOutputStream.flush(CoyoteOutputStream.java:101)
at com.opensymphony.module.sitemesh.filter.RoutableServletOutputStream.flush(RoutableServletOutputStream.java:122)
at com.fasterxml.jackson.core.json.UTF8JsonGenerator.flush(UTF8JsonGenerator.java:1045)
at com.fasterxml.jackson.databind.ObjectMapper.writeValue(ObjectMapper.java:1821)
at org.springframework.http.converter.json.MappingJackson2HttpMessageConverter.writeInternal(MappingJackson2HttpMessageConverter.java:204)
at org.springframework.http.converter.AbstractHttpMessageConverter.write(AbstractHttpMessageConverter.java:179)
at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMethodProcessor.java:148)
at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMethodProcessor.java:90)
at org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.handleReturnValue(RequestResponseBodyMethodProcessor.java:189)
at org.springframework.web.method.support.HandlerMethodReturnValueHandlerComposite.handleReturnValue(HandlerMethodReturnValueHandlerComposite.java:69)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:122)
主要問題描述的是:寫入的響應頭的資料超出緩衝區限制的大小,建議修改maxHttpHeaderSize的值,或者減少響應頭的資料!
解決方案:
找到tomcatan'z安裝目錄下的 sever.xml
修改內容
把maxHttpHeaderSizesh,設定變大就好了。
<Connector port="8081" maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true" />