RequestParam get array from select option html form

spring-mvc

Solution

I don't think that spring will convert a parameter array to a specific type other than String, so you should try the following:

@RequestParam(value = "t", required = true) String[] t

and then use `Integer.parseInt()` to convert the String to an int.

Problem

I am trying to get multiple values from a multiple select option box in html. I get in to my controller: ``` /test?t=1&t=2&t=3 ``` In the controller, I try to get the int array: ``` @RequestParam(value = "t", required = true) int[] t ``` But when I check it using: ``` t.length ``` I only see 1, which means Spring only gets 1 parameter, but I expected 3. Anybody have any idea?

Original source