javax validation not working on method parameters.. This is a test code and none of javax validation works on method parameter...
@RequestMapping(value = "/{id}", method = RequestMethod.PUT, params = "action=testAction")
public Test update(
@Size(min = 1) @RequestBody List<String> ids,
@Min(3) @PathVariable String name) {
return doSomething(ids, name);
}
But i have class level validations which works perfectly...
@RequestMapping(method = RequestMethod.POST)
@ResponseStatus(HttpStatus.CREATED)
public RoleType create (@RequestBody @Validated(FieldType.class) User user) {
...
}
And
@Size(min = 2, max = 10, groups = { FieldType.class }, message = "Invalid user code")
public String getId() {
return _id ;
}
-- Solution --
all steps followed as per the accepted answer. And another addition is annoation on class level
@Validated
class UserController
{
@RequestMapping(value = "/{id}", method = RequestMethod.PUT, params ="action=testAction")
public Test update(@Size(min = 1) @RequestBody List<String> ids,@Min(3) @PathVariable String name) {
return doSomething(ids, name);
}
}