Bax
Bax

Reputation: 4476

Spring 4 Optional<List<String>> @RequestParam

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'
}

Upvotes: 5

Views: 3160

Answers (1)

khong07
khong07

Reputation: 366

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

Upvotes: 4

Related Questions