Spring Boot: How to ignore case when using an Enum as a Request parameter
Here is a way to enable the use of case-insensitive enumerations request parameters. You won’t need to do any code modification in your enum.
Let’s say you have a controller class:
And an Enumeration:
You have to create a custom Spring converter that converts String into MyEnum:
Tests:
GET /test/hEy
will returnHey HEY
GET /test/HELLO
will returnHey HELLO
GET /test/hello
will returnHey HELLO
Tested with Spring Boot 2.2.6