【发布时间】:2012-08-25 09:43:09
【问题描述】:
我在控制器中调用索引方法
def index() {
childInstance = Child.get(params.id)
if(childInstance){
System.out.println("CHILD" + childInstance.firstname)
def messages = currentUserTimeline()
[profileMessages: messages,childInstance:childInstance]
} else {
def messages = currentUserTimeline()
[profileMessages: messages]
System.out.println("ALL")
}
}
在我的gsp页面中
${childInstance.firstname}
如果我传递一个 childInstance 这很好,但如果我不传递一个空指针,我会得到 500,有没有办法我可以在 gsp 中执行 if 语句,这样我就可以做到这一点
if(childInstance){
${childInstance.firstname}
} else {
All
}
【问题讨论】:
标签: grails