Bean验证框架 Hibernate Validator

fmms 12年前
     <p>用Annotations 给类或者类的属性加上约束(constraint),在运行期检查属性值是很优雅的.Hibernate Validator就是这样的一个框架.该框架是十分容易的(就像参考文档中宣称的那样),几乎没有什么学习曲线,Validator 是一个验证框架 不需要和Hibernate的其他部分绑定就可以使用,只要在你的项目中添加Hibernate-annotations.jar库就可以了.</p>    <p>示例代码:</p>    <pre class="brush:java; toolbar: true; auto-links: false;">public class Address {      @NotNull private String line1;     private String line2;     private String zip;     private String state;          @Length(max = 20)     @NotNull     private String country;      @Range(min = -2, max = 50, message = "Floor out of range")     public int floor;          ... }</pre>    <p></p>    <p><strong>项目主页:</strong><a href="http://www.open-open.com/lib/view/home/1326112512328" target="_blank">http://www.open-open.com/lib/view/home/1326112512328</a></p>