How do I solve this exception?

java.lang.IllegalArgumentException: Request header is too large
Copy the code

Abnormal reason

The Exception MessageRequest header is too large.

This article is the first program ape DD blog, welcome to collect attention!

How to solve

There are two main solutions:

Direction 1: Configure the maximum value the application server allows > the size of the request header data that you want to use

With Spring Boot, you just need to configure this parameter in the configuration file:

server.max-http-header-size=
Copy the code

Direction 2: Avoid the situation that the request header is too large

The above configuration can be fixed, but if the header part is used indiscriminately, this parameter becomes uncontrollable.

It’s not recommended to put too much data in the header itself, so it makes more sense to put the data in the body.

So when you get this exception, do you choose method one or method two? Or is there another way? Comment on which one you think is better!

Welcome to pay attention to my public account: program ape DD, share the outside can not see the dry goods and thinking!