Hi,
I am using Spring 3.1 for REST controller & trying to validate integer in request param.
I tried following options:Code:@Controller public class MyController { @RequestMapping(value = "/v1/mymapping", method = RequestMethod.GET, produces = { "application/json", "application/xml" }) @ResponseBody public List<MyObject> getResponse(@RequestHeader("Accept") final String acceptHeader, @RequestParam(value = "count", required = false, defaultValue="20") final Integer count ) throws Exception { .............. .............. .............. }
- using oval validation
Code:@RequestParam(value = "count", required = false, defaultValue="20") @NotNegative final int count- Using regex
Code:@RequestParam(value = "count:[1-9][0-9]", required = false, defaultValue="20") final int count
None of the above options are working. Is there any way in spring to validate request param of type integer?


Reply With Quote
