@RequestParam array mapping issues

Sending lists of items in the URL is tricky. In general, the request

/rest/table?filter=A&filter=B

and

/rest/table?filter=A,B

will both get parsed as if A and B are individual parameters. This is because Spring's default WebDataBinder is configured to split parameters lists on commas. You can disable this default configuration by adding some binder initialization code to your controller.

@InitBinder
public void initBinder(WebDataBinder binder) {
    binder.registerCustomEditor(
        String[].class,
        new StringArrayPropertyEditor(null)); 
}

Now the data binding process for parameter lists coming in over HTTP will not be split on the comma, and be interpreted as separate items. This will likely produce the behavior you're looking for, so that comma-delimited parameter lists will be treated as a single array parameter rather than N separate single-item array parameters.

Tags:

Java

Spring