Problem with resolution of spring's @RequestParam with Kotlin


in Java

You can either call ?params=1,2 or ?params=1&params=2 no matter if your request param is declared using @RequestParam List<Integer> params inside signature of controller method, or it is a field of external class that’s used to group all request params of controller method.

In Kotlin

if you declare your request param inside of controller method signature, as a @RequestParam params: List<Int> you can call it using both methods, so:

?params=1,2 and ?params=1&params=2

If you however, extract it to separate data class, and then expect this class to be populated in controller method, you can only do the ?params=1&params=2, because in the case of ?params=1,2 you get:

org.springframework.validation.BindException because it tries to parse entire ‘1,2’ instead of split it first.

Does anybody know why this happens? It is quite important for us as we’re migrating to Kotlin, and customers are used to call ?params=1,2, as well as we want to extract these params to separate class because there are many of them.