jeudi 9 avril 2015

Making Request parameter binding case in sensitive

I have a requirement where i have to make requestParams to bind properly even if the cases of the param name changes.Note:I am using spring 3.2


For eg: http://localhost:8080/sample/home?userName=xxx or http://localhost:8080/sample/home?username=xxx or http://localhost:8080/sample/home?usernaMe=xxx should map proplery to my @requestParam value.



@RequestMapping(value = "home", method = RequestMethod.GET)
public goToHome(@RequestParam(value = "userName", required = false) String userName){

}


All the three urls should call the above method and bind the user name properly. Please give suggestions on how to implement this by implementing new argument handler resolver ? Overriding spring config classes to implement generically is preffered over changing the logic in the code for all @requestParam.


Aucun commentaire:

Enregistrer un commentaire