I am learning myself Spring MVC 2.5 mainly from the docs. Can someone explain the following:
- Advantages / Differences in Using
command Objects Compared to Using @ModelAttribute to @ModelAttribute in an Object. - Is there an easier way to do validation and then write a Validator object?
Also, in this code, how does the line ValidationUtils.rejectIfEmpty(e, "name", "name.empty"); ? How can he check if a person’s name is empty when the person’s object is not transferred?
public void validate(Object obj, Errors e) { ValidationUtils.rejectIfEmpty(e, "name", "name.empty"); Person p = (Person) obj; if (p.getAge() < 0) { e.rejectValue("age", "negativevalue"); } else if (p.getAge() > 110) { e.rejectValue("age", "too.darn.old"); } }
(this code is from section 5.2 of the documents )
thanks
source share