1
我明白,BindingResult是用於與表單有關的驗證錯誤。但是,怎麼樣經營錯誤,例如: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>
是否有類似的通用結構,把企業的錯誤?
感謝Jelies格式化JSP/HTML片段 – 2012-07-30 08:38:47
沒有問題卡洛斯:) – jelies 2012-07-30 09:31:34
http://stackoverflow.com/questions/3101148/how-to-add-error-上彈簧MVC-simpleformcontroller – Saurabh 2012-07-30 10:18:09