对于其他时间使用,您不仅可以在 myObject.save() 之类的域对象上使用此显示错误方法,还可以在任何具有异常或类似服务的方法上使用此方法:
def searchService
searchService.search(person) // inside hibernate create criteria or any db actitvity or ...
seachService.errors.allErrors,each {
flash.message = message(code:'default.search.error.message',default : it) //see it in freindly view
//Or println("${new Date()}"it)
}
you need a lable flash message on your in case of other files than bootstrap
<g:set var="entityName" value="${message(code: 'domainClassName.label', default: 'what ever')}" />
<title><g:message code="default.list.label" args="[entityName]" /></title>
<h1><g:message code="default.list.label" args="[entityName]" /></h1>
<g:if test="${flash.message}">
<div class="message" role="status">${flash.message}</div>
</g:if>