服务验证域模型



我遇到了来自服务域验证的消息方法的问题。有人知道如何解决这个问题吗?以下是服务方法。当我的控制器打电话时:glossaryService.post(params, 'save')

@Transactional
class GlossaryService {
//  Saving glossary
def post( def params,def currentURI ) {
    params.status = params.status ? Status.PUBLISHED.value() : Status.DRAFT.value()
    def result = [success: false, message: ""]
    def glossary = null
    if (params.action == 'save') {
        glossary = new Glossary(params)
    } else if (params.action == 'update') {
        glossary = Glossary.get(params.id)
        glossary.name = params?.name
        glossary.description = params?.description
        glossary.glossaryTerm = params?.glossaryTerm
        glossary.status = params?.status
    }
    if (glossary.validate()) {
        result = glossary.save(flush: true, failOnError: true)
    }
    if (glossary.hasErrors()) {
        transactionStatus.setRollbackOnly()
        result.errors = glossary.errors
        def errors = glossary.errors.allErrors.collect {
            message(error: it)
        }
        respond glossary.errors, view: '/admin/glossary/'+currentURI, model: [
                glossary: params
        ]
        return
    }
    return result
}
}

提示的错误是:

班级:groovy.lang.missingmethodexception

消息:没有方法的签名:com.content.glossaryservice.message()适用于参数类型:(字段"名称":拒绝值[null];代码[COM.CONTENT.GLOSSARY.NAME.NALEBALE.ERROR.COM.CONTENT.GLOSSARY.NAME,COM.CONTENT.GLOSSARY.NAME.NAME.NAME.NAME.NAME.NAME,com.content.glossary.name.name.name.name.name.name.nullable.eror.error.error.java。lang.String,com.content.glossary.name.name.error,glossary.name.nullable.error.com.content.glossary.name,glossary.name.name.name.errable.error.error.name,glossary.name.name.name.name.nullable.error。java.lang.string,glossary.name.nullable.error,com.content.glossary.name.name.name.name.com.content.glossary.name,com.content.glossary.name.name.name.nullable.nullable.name,com.content.glossary。名称。lang.String,glossary.name.name.nullable,nullable.com.content.glossary.name,nullable.name,nullable.java.lang.lang.string,nullable];参数[name,com.content.glossary class com。class [{1}]的默认消息[property [{0}]不能为null]]]可能的解决方案:iscase(java.lang.object)

注入messageSource

MessageSource messageSource

然后使用它

messageSource.getMessage(...)

相关内容

  • 没有找到相关文章

最新更新