I have a Spring 3.2 Controller with basic request mappings like
@RequestMapping("/action")
public String action(@RequestParam("param") String param) {
//do stuff...
return "view";
}
This controller handles links created by non-technical business users. Sometimes the users mess it up and create links with duplicate parameters, e.g.,
www.example.com/action?param=value¶m=value
The parameter is an exact duplicate and probably a copy/paste error.
My problem is that Spring is concatenating these dupes together, so that the url above will give "value,value"
for param
, when I want only "value"
.
What is a good way to detect and handle these duplicates? I know I could change all my @RequestParam
s to List<String>
s and go from there, but that's a whole lot of boilerplate over dozens of request mappings.
Ideally there would be a way to intercept and modify the url parameters before Spring attempts to bind them -- but only for this controller.