日期:2014-05-19 浏览次数:20724 次
@RequestMapping(value="/add",method=RequestMethod.POST)
public String addbinder(@Valid User user,BindingResult result) {
if(result.hasErrors()){
System.out.println("binder fail!");
return "ssuubb";
}else{
System.out.println("********************");
System.out.println(user.getNumber()+"here");
System.out.println(user.getAddress());
System.out.println(user.getPassword());
System.out.println("********************");
return "file";}
}
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.hibernate.validator.constraints.NotEmpty;
public class User{
@NotNull
private String number ;
@Size(max=20,min=10)
private String password ;
@NotEmpty
private String address ;
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getNumber() {
return number;
}
public void setNumber(String number) {
this.number = number;
System.out.println("user is ok");
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}