I have some problems with how spring binds parameters.
In my scenario I want a controller method that accepts only one query argument 'q':
@Controller
@RequestMapping("/home")
public class HomeController {
@RequestMapping
public void test(@RequestParam(value = "q") final String q) {
System.out.println("> " + q);
}
}
Now if I send the valid request in terms of my specification:
GET /home?q=cat
I get expected output:
> cat
And if I send the request that is not valid in terms of my specification, but remains valid as http request:
GET /home?q=cat&q=black
I get ambiguous and unexpected result ( I have idea about why spring doing it... arrays binding, etc. :) But it remains a surprise. ):
> cat,black
I can't use those parameters, they are can be invalid. But I have no simple way to validate request.