我该如何分辨
我正在尝试使用注释使用Spring 3.0验证。http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/validation.html#core-core-core-cornvert
我的代码在文档中看起来像:
@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");
}
}
是否通过验证是否通过?
aah ...这很微不足道...刚发现我的请求图中有一个bindingResult参数,该参数具有HaserRors()方法。