按照GORM 文档,我尝试在 Grails 2.2.1 中使用以下域类:
package grailscompositiontest
class ScafPerson {
String name
ScafAddress homeAddress
ScafAddress workAddress
static constraints = {
name(nullable: false, blank: false)
}
static embedded = ['homeAddress', 'workAddress']
}
class ScafAddress {
String number
String code
}
控制器只使用脚手架:
package grailscompositiontest
class ScafPersonController {
static scaffold = true
}
不幸的是,这不起作用,一旦我浏览到“创建”视图,它就会触发服务器错误:
URI: /GrailsCompositionTest/scafPerson/create
Class: java.lang.NullPointerException
Message: Cannot get property 'id' on null object
知道我做错了什么吗?