5

Using java.util.Optional as a spring controller request parameter.

For simple values (int, String, etc) it works as expected but for a parameter which is of type List<String> or String[] and for which I pass multiple values:

    mockMvc.perform(get("/get").param("param", "value1", "value2"))

it always picks just one value of the passed ones.

@RequestMapping(value = "/get", method = RequestMethod.GET)
public Object get(@RequestParam(name = "param") Optional<String[]> array) {
    // the array will have just 1 element : 'value1'
}
Bax
  • 4,260
  • 5
  • 43
  • 65

1 Answers1

4

this issue will be resolved in next spring web release 4.3 https://jira.spring.io/browse/SPR-13418

khong07
  • 316
  • 1
  • 4
  • 10