I have the following which works well in receiving a non-empty Array,
$.ajax({
url: "ajaxController",
dataType: "json",
type: "get",
data: {
'term': request.term,
'exclude': ["45","66"]
},
Controller (note the [] in RequestParam Value -- the result goes in a String[]):
public List<KeyValueBean> getChoices(String term,
@RequestParam(value = "exclude[]")
String[] exclude) {
}
But if I pass an empty array in the same code, which sometimes happens, it breaks:
'exclude': []
or alternatively
'exclude': JSON.stringify([])
Error:
org.springframework.web.bind.MissingServletRequestParameterException: Required
String[] parameter 'exclude[]' is not present