Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/grails/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Grails中显示异常?_Grails_Grails 2.0_Grails Controller_Grails Validation - Fatal编程技术网

如何在Grails中显示异常?

如何在Grails中显示异常?,grails,grails-2.0,grails-controller,grails-validation,Grails,Grails 2.0,Grails Controller,Grails Validation,a我的代码有问题。我如何处理gsp服务中的错误?我尝试从服务或控制器进行渲染,调用save()时发生验证错误:-字段“core.db_email”上的对象“talent.CandidateProfile”中的字段错误:拒绝值[];具有完整异常跟踪的代码。我的资料来源: def create() { [candidateProfileInstance: new CandidateProfile(params)] } def save() { de

a我的代码有问题。我如何处理gsp服务中的错误?我尝试从服务或控制器进行渲染,调用save()时发生验证错误:-字段“core.db_email”上的对象“talent.CandidateProfile”中的字段错误:拒绝值[];具有完整异常跟踪的代码。我的资料来源:

 def create() {
        [candidateProfileInstance: new CandidateProfile(params)]
    }

    def save() {
        def candidateProfileInstance = new CandidateProfile(params)
        if (!candidateProfileInstance.save(flush: true)) {
            render(view: "create", model: [candidateProfileInstance: candidateProfileInstance])
            return
        }

        flash.message = message(code: 'default.created.message', args: [message(code: 'candidateProfile.label', default: 'CandidateProfile'), candidateProfileInstance.id])
        redirect(action: "show", id: candidateProfileInstance.id)
    }
我的.gsp页面代码

<div class="full-filed">
            <h3>Email Address:</h3>
        </div>
        <div    class="fieldcontain ${hasErrors(bean: candidateProfileInstance, field: 'core.db_email', 'error')} ">
            <label for="core.db_email" class="error_message"> <g:message
                    code="candidateProfile.core.db_email.label" default="Dbemail" />
            </label>
        </div>
        <g:textField name="core.db_email" value="" class="loginTxtBox" placeholder="Email Address" />

电邮地址:

我只想向用户显示一个错误,而不是完整的异常跟踪

//grails.gorm.failOnError=true

只需对此行进行注释…这样它就会显示您的自定义错误