欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  资讯频道

Spring 3.0.0 Release Candidate 1发布

程序员文章站 2022-04-20 21:13:31
...
This news just in from Arjen Poutsma's twitter feed: Spring 3.0.0.RC1 is now available.
http://s3.amazonaws.com/dist.springframework.org/milestone/SPR/spring-framework-3.0.0.RC1-with-docs.zip

新的Validator不错


Spring 3 Validation
public class Person {
   @NotNull
   @Max(64)
   private String name;
   @Min(0)
   private int age;
}


@Controller
public class MyController {
   @InitBinder
   protected void initBinder(WebDataBinder binder) {
      binder.setValidator(new FooValidator());
   }
   Spring Framework 3.0.0.RC1 Reference Documentation 143
   @RequestMapping("/foo", method=RequestMethod.POST)
   public void processFoo(@Valid Foo foo) { ... }
}




<!-- Invokes Spring MVC @Controller methods -->
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="webBindingInitializer">
<!-- Configures Spring MVC DataBinder instances -->
<bean class="org.springframework.web.bind.support.ConfigurableWebBindingInitializer">
<property name="validator" ref="validator" />
</bean>
</property>
</bean>
<!-- Creates the JSR-303 Validator -->
<bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean" />
相关标签: Spring