In Spring MVC 2.0-RC4, when I've passed the validation checks but encounter an error condition (a Db/logic error, not a field validation error) in onSubmit(), I set the errors/BindException object and return:
The form view is returned but there are no error messages printed on the page. I have this snippet on the .jsp to print error messages:Code:protected ModelAndView onSubmit(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object command, BindException errors) throws Exception { BizObject bizObject = (BizObject) command; ... if (someDbCheckFails) { ModelAndView mav = new ModelAndView(getFormView(), "bizObject", bizObject); errors.reject("db.error.condition"); mav.addObject("errors", errors); return mav; } ...
There is no exception or stack trace. Any idea why the errors are not printing? There are no specific examples of this in any of the four books I've read on Spring; they only cover the simplest field-related validation errors. (TIA!)Code:<spring:bind path="bizObject.*"> <c:if test="${not empty status.errorMessages}"> <div class="error"> <c:forEach var="error" items="${status.errorMessage}"> <c:out value="${error}" escapeXml="false"/><br/> </c:forEach> </div> </c:if> </spring:bind>


Reply With Quote
)
