将方法的参数保存到另一个方法。
将人的参数保存在def contentPerson
中的saveperson
方法中。有人知道如何保存参数吗?没有找到我的方法savework
。
def saveperson(Person personIntance) {
def contentPerson =personInstance.save(flush:true)
redirect(controller:'Person', action:'creatework')
flash.message="I automatically select the person id";
}
def savework(Work workInstance,contentPerson) {
def work1 = new Work(name:params.name,person:contentPerson, profession:params.profession)
work1.save(flush:true)
}
消息:
没有这样的财产:
contentPerson
发布于 2016-01-07 13:09:46
重定向进行了一个全新的调用,因此它是一个完全不同的上下文。您可能想试试这个:
redirect(controller:'Person', action:'creatework', params:[contentPerson: contentPerson])
或者用闪光灯保存,就像这样:
flash.contentPerson = contentPerson
您可以将它用于另一个请求,如下所示:
flash.contentPerson
但你应该避免使用闪光灯。所以最好是通过参数。
https://stackoverflow.com/questions/34644127
复制相似问题