gpt4 book ai didi

grails - 无法在grails中调用方法本身

转载 作者:行者123 更新时间:2023-12-02 14:56:57 25 4
gpt4 key购买 nike

当我尝试在方法体内自行调用方法时,项目出现错误。我把代码放在gsp中。

他们来了

/* Method for appending the child menu */
def createMenuChild = { obj , paramMenuArr ->
def urlChildMenu=obj.menu.url
def idChildMenu=obj.menu.id
def nameChildMenu=obj.menu.name

out << '<div><a href="'+urlChildMenu+'" class="mChld">'<< nameChildMenu<< '</div>'

def childInstance1= Menu.findById(idChildMenu)
def child1MenuInstance= Menu.createCriteria().list{
eq("parentMenu",childInstance1)
order("sequence", "asc")
}
if (child1MenuInstance){
child1MenuInstance.each {newIt5 ->
def idChildMenu2=newIt5.id
paramMenuArr.each { newIt6 ->
if (newIt6.menu.id == idChildMenu2){
owner.call (child1MenuInstance,paramMenuArr)
}
}
}
}
}

我使用 owner.call 来调用方法本身。我有这样的错误
Exception Message: No signature of method: bla.....

有人可以解决吗?

最佳答案

I put my code in gsp.



您确实应该将这种代码放入taglib中。

Anybody can fix it?



如果这只是一个标准的递归方法,那么执行递归调用的明显方法是:
createMenuChild(child1MenuInstance,paramMenuArr)

尝试使用它代替
owner.call (child1MenuInstance,paramMenuArr)

关于grails - 无法在grails中调用方法本身,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6122626/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com