0

@RequestMapping 方法启动后是否可以运行@Validated?原因是我需要在实际验证之前修改@ModelAttribute。

理想情况下是这样的。

@RequestMapping(value = "/doSomething",
        method = RequestMethod.POST)
public final String DoSomething(
        @ModelAttribute(value = "myobject") final MyObject myobject) {
   //.... do some processing on myobject
   //.... now validate
   BindingResult bindingResult = validate(myobject);
   //... 

还有这样的方法

private final BindingResult validate(
        @Validated(value = {Group1.class, Group2.class}) MyObject myobject) {

  return bindingResult //somehow return a BindingResult
}
4

1 回答 1

0

使用您自己的自定义验证器

http://static.springsource.org/spring/docs/3.2.x/spring-framework-reference/html/validation.html#validation-binder

于 2013-08-05T02:00:13.603 回答