2013-05-21 3 views
0

에 내 코드에 문제가 있습니다. 어떻게하면 서비스에서 내 gsp로 오류를 처리 할 수 ​​있습니까? 내가 서비스 또는 컨트롤러에서 렌더링과 함께 그것을 시도, 저장() 호출 중에 검증 오류가 발생했습니다 : - 'core.db_email'필드의 'talent.CandidateProfile'객체의 필드 오류 : 거부 된 값 []; 전체 예외 추적 코드. 내 소스 :Grails에서 예외를 표시하는 방법?

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) 
    } 

내 내가 원하는

<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" /> 

그냥 사용자 오류로 보여 .gsp 페이지 코드가 아닌 전체 예외 추적

답변

0

형성하여 config.grooyPage

//grails.gorm.failOnError = true

그냥이 줄에 주석을 달아주세요 ... 그래서 사용자 정의 오류를 표시합니다

+0

감사합니다 ... 감사합니다. 너무 많이 @smprogrammer –

관련 문제