3
Grails 애플리케이션에서 Java 개체 클래스를 Java 개체 클래스로 사용하고 있습니다. 이러한 클래스에는 JSR 303 유효성 검사 주석 (@Size, @NotEmpty 등)이 있습니다.Grails : JSR 303 빈 검증을 처리하는 방법
는 콘트롤러와 뷰는이 엔티티 클래스와 함께 잘 작동,하지만 깨진 제약 인스턴스 (@NotEmpty 필드의 빈 값)을 저장하려고하면, 나는 다음과 같이 오류 페이지를 얻을 :
/webcall-account-manager-2/company/save
Class
javax.validation.ConstraintViolationException
Message
Validation failed for classes [com.rcslabs.webcall.server.model.Company] during persist time for groups [javax.validation.groups.Default, ] List of constraint violations:[ ConstraintViolationImpl{interpolatedMessage='may not be empty', propertyPath=name, rootBeanClass=class com.rcslabs.webcall.server.model.Company, messageTemplate='{org.hibernate.validator.constraints.NotBlank.message}'} ]
Around line 27 of grails-app/controllers/com/rcslabs/webcall/server/model/CompanyController.groovy
24: def save() {
25: def companyInstance = new Company()
26: companyInstance.properties = params
27: if (!companyInstance.save(flush: true)) {
28: render(view: "create", model: [companyInstance: companyInstance])
29: return
30: }
Trace
Line | Method
->> 251 | call in org.grails.datastore.gorm.InstanceMethodInvokingClosure
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 27 | save in CompanyController.groovy
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 603 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 679 | run . . . in java.lang.Thread
올바른 방법 (필드 위의 메시지 상자)에서 처리하기 위해 수행 할 수있는 작업은 무엇입니까?
companyInstance.validate()가 true를 반환합니다. – weekens