如何在 spring boot 2.x 应用程序中设置 max-http-header-size

2022-09-02 11:34:58

我有运行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


答案 1

您应该在“应用程序.属性”文件上设置:

server.max-http-header-size=48000

48000 是过多标头的一个示例,请随意放置任何内容。


答案 2

从Spring boot 2.1开始,您现在需要使用可解析值。例如:DataSize

server.max-http-header-size=40KB

推荐