I have a spring controller method that receives some optional arrays as parameters. They are not required, but I'd like them to be not null, but just empty arrays when they are are not in the parameters which are received by the controller method. I know, I could check them for being null and then assign as new object, but that would generate lots of boilerplate code. Also, when I try to do something like this:
@RequestMapping(headers = "Accept=application/json", method = RequestMethod.GET, value = "/socialUsers/saveFilter", produces = "application/json")
public @ResponseBody
void saveFilterToDataBase(@RequestParam(required = false, value = "gender", defaultValue = "{}") Gender[] genders)
....
I receive the 400th error, when I don't provide the parameter in the url, which is weird, cause the required field is false.
Any ideas on that, guys?
{}?