帖子很旧,但这是我的解决方案。
import org.codehaus.groovy.grails.commons.ApplicationHolder
def myCommand = new MyCommand()
myCommand.errors.reject('Foo error')
myCommand.errors.reject('Bar message')
myCommand.errors.reject('myCommand.myfield.nullable')
def appHolder = ApplicationHolder.application.mainContext.getBean('org.codehaus.groovy.grails.plugins.web.taglib.ApplicationTagLib')
def list = myCommand.errors.allErrors.collect{appHolder.g.message([error: it])}
list
结果:
["Foo error","Bar message","Property myfield cannot be null"]