我有运行Java 11的Spring启动应用程序:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
我收到错误:java.lang.IllegalArgumentException: Request header is too large
如何提高max-http-header-size
?
你应该在"application.properties"文件上设置:
server.max-http-header-size=48000
48000 是过多标题的一个例子,随心所欲。
从 Spring boot 2.1 开始,你现在需要使用一个DataSize
可解析的值。
server.max-http-header-size=40KB
请尝试server.max-http-header-size
。我在这里找到了它:常见的应用程序属性。
Tomcat and Jetty 的默认值为 8KB,Undertow 的默认值为 1MB。
在春季启动 1.3.5.发布中,对我有用的是在 application.properties 中设置以下条目:
server.tomcat.max-http-header-size=100000
自 Spring Boot 3 以来,max-http-header-size
属性已弃用。
现在您可以使用max-http-request-header-size
:
server:
max-http-request-header-size: 12KB
注意:该值必须是DataSize
,这很干净。您可以使用1KB
而不是1000
。数据大小文档