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:
- RequestParam value in spring MVC to be case insensitive
- Is there any way we make PathVariable name case insensitive in Spring?
- Spring mvc. case insensitive get parameters mapping
- Making a request parameter binding 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?