I am using Spring MCV and if I annotate my controller method with the DefaultValue annotation I am getting a serialization error
@RequestMapping(value = "/page", method = RequestMethod.GET)
page(@DefaultValue("10") @QueryParam("pageSize") int pageSize
Returns the following error if I don't pass the pageSize parameter to the controller:
Optional int parameter 'pageSize' is present but cannot be translated into a null value due to being declared as a primitive type. Consider declaring it as object wrapper for the corresponding primitive type.
Am I misusing DefaultValue here?
You are mixing two implemetation, Spring and JAX-RS, if you are using Spring then you can have code like:
@RequestMapping(value = "/page", method = RequestMethod.GET)
public String page(@RequestParam(name = "pageSize", defaultValue = "10") int pageSize) {
}