2

I would like all my APIs to use lower-case request parameters, but I would still like to use camel-case in my Java code.

For example, consider the following code:

@GetMapping("/ping")
public String ping(
    String responseMessage)
{
    return "PONG " + responseMessage;
}

To contact this endpoint and supply a response message, I would have to call: localhost:8080/ping?responseMessage=Hello. However, I would like spring to automatically bind the variable name responseMessage to a request parameter named responsemessage. I specifically do not want to manually write @RequestParam(name="responsemessage") in my controller, but rather configure a global naming strategy for request parameters. Is this possible?

There are a couple of other threads on SO that talks about making the request parameters or url mappings case-insensitive:

However, the answers in these questions strikes me as quite hacky or requires manual codeing. Is there no simple setting for the behaviour I am after? I know this is possible when using JSON bodies, by configuring the Jackson propertyNamingStrategy. Is there an equivalent for request parameters?

Gikkman
  • 752
  • 6
  • 21
  • This thread might be helpful https://stackoverflow.com/questions/29531786/making-a-request-parameter-binding-case-insensitive – Vishal Sharma Jul 06 '18 at 09:26

0 Answers0