我了解 BindingResult 用于与表单相关的验证错误。但是,业务错误呢,例如:
public String bulkUpdate(@ModelAttribute form, BindingResult r) {
//do validation, extract selected issues to be bulk updated, etc.
//any form related, binding errors to be put in r
//this part
List<String> results = service.bulkUpdate(issues, newValues);
//where is it appropriate to put the results?
//from experience we just create a request attribute and put it there
request.setAttribute("bulkUpdateErrors", StringUtils.join(results, "<br>"))
//is there an similar generic structure like Errors?
}
在jsp中:
<div id='info'>
<c:if test="${not empty bulkUpdateErrors}">
<spring:message code="bulk.update.warning" /> ${bulkUpdateErrors}
</c:if>
</div>
是否有类似的通用结构来放置业务错误?