Chaitan K Pirannawar
Chaitan K Pirannawar

Reputation: 11

how to read a single header for @RequestHeader annotation even if the user gives the duplicate headers

How to read a single header for @RequestHeader annotation even if the user gives the duplicate headers. If the user gives two header with same key it is been read as comma separated values. I want it to behave like read always first value and ignore other values. I want it to behave like read always first value and ignore other values. Spring by default executes request.getHeaders("key") which returns comma separated value if the key present more than once.

Any suggestions?

Upvotes: 1

Views: 399

Answers (1)

aurelius
aurelius

Reputation: 4076

One easy way is to split the value of the key with yourString.split(";") and get the first value of the array, if not null though

Upvotes: 1

Related Questions