【发布时间】:2012-08-29 18:31:59
【问题描述】:
我有一个 gsp 文件,它调用这样的方法:
<g:link id="${child.id}" action="callChildProfile" controller="profile">${child.firstname}</g:link>
调用这个方法
def callChildProfile(Long id){
childInstance = Child.get(id)
System.out.println(childInstance.firstname + " child instance")
redirect(action: "index")
}
此方法将一个子实例设置为一个称为子实例的公共变量,但是当重定向发生时,该变量会被重置。 我重定向的原因是因为我想从这个控制器加载索引页面。
索引如下所示:
def index() {
def messages = currentUserTimeline()
[profileMessages: messages]
System.out.println(childInstance + " child here")
[childInstance : childInstance]
}
【问题讨论】:
标签: grails