我有这个简单的bean:
public class Person {
@Min(value=18,message="Wrong!")
private int age;
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
}
我将在age
上测试验证,我在servlet中使用它:
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
Person p=new Person();
p.setAge(7);
response.getWriter().print(p.getAge());
}
我设置年龄= 7但我没有例外或任何消息,它返回7!为什么呢?