0
我有兩個類(豆)如何驗證在Spring控制器方法兩個或兩個以上豆Hibernate驗證(JSR 303)
public class BeanOne {
@Min(1)
private Integer idBeanOne;
@NotBlank
private String nameBeanOne;
@NotNull
@Min(1)
private Integer idOther;
// ... Getters and Setters
}
public class BeanTwo {
@Min(1)
private Integer idBeanTwo;
@NotBlank
private String nameBeanTwo;
@NotNull
@Min(1)
private Integer idOtherTwo;
// ... Getters and Setters
}
春
// Method in Controller
@RequestMapping(value = "/name.html", method = RequestMethod.POST)
public @ResponseBody
Map<String, Object> submitInsert(@Valid BeanOne one,
@Valid BeanTwo two, BindingResult result) {
if (result.hasErrors()) {
// Errores
} else {
// :D
}
}
的控制器有什麼辦法我可以驗證兩個或更多的豆子?我已成功驗證了單個bean,但是我沒有成功驗證兩個或更多的bean。我怎樣才能做到這一點? 感謝:D 感謝:D