我正在尝试使用注释使用 Spring 3.0 验证。 http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/validation.html#core-convert
我的代码在文档中看起来像:
@Controller
public class MyController {
@InitBinder
protected void initBinder(WebDataBinder binder) {
binder.setValidator(new FooValidator());
}
@RequestMapping("/foo", method=RequestMethod.POST)
public void processFoo(@Valid Foo foo) { ... }
}
public class PersonValidator implements Validator {
/**
* This Validator validates just Person instances
*/
public boolean supports(Class clazz) {
return Person.class.equals(clazz);
}
public void validate(Object obj, Errors e) {
ValidationUtils.rejectIfEmpty(e, "name", "name.empty");
}
}
如何在我的 RequestMapping 方法中判断验证是否通过?