Grails模式在出错时重用模板

Grails模式在出错时重用模板,grails,gsp,Grails,Gsp,我有一个gsp模板,其中创建视图的数据通过控制器传递 def create = { def bookInstance = new Book() bookInstance .properties = params def map = getDefaultValues() render(template: "create", model: [bookInstance : bookInstance , title: map.title, some

我有一个gsp模板,其中创建视图的数据通过控制器传递

def create = {
    def bookInstance = new Book()
bookInstance .properties = params
def map = getDefaultValues()
render(template: "create", model: [bookInstance : bookInstance ,
            title: map.title,
            somelist: somelist
            ....])
普惠制模板

 <g:select optionKey="id" from="${somelist}" name="somelist.id" value="${bookInstance ?.somelist?.id}" noSelection="['null': '']"></g:select>
但gsp(保存操作中呈现的错误页面)中的字段为空。我可以看到原因,因为它在
“${somelist}”
中查找值,但它没有在save方法中使用。我是否只需要在gsp中检查null并使用可用的映射,或者使用任何更好的方法(在save方法中传递所有映射不是一个选项)

提前谢谢..

我想起来了。。我必须传递与create闭包中相同的映射。。我们在create中传递映射的原因是我们想覆盖默认列表。。bookInstance中填充的值仅用于保留用户选择,而不是所有值

我想出来了。。我必须传递与create闭包中相同的映射。。我们在create中传递映射的原因是我们想覆盖默认列表。。bookInstance中填充的值仅用于保留用户选择,而不是所有值

render(template: "create", model: [bookInstance : bookInstance ])