gpt4 book ai didi

variables - 带有变量的Grails FindAllWhere

转载 作者:行者123 更新时间:2023-12-02 15:02:13 24 4
gpt4 key购买 nike

我试图在grails gsp中执行一次findAllWhere,传入两个变量:一个是属性,一个是我希望该属性相等的值。 I.E(作者:Mark Twain)我无法弄清楚语法,收到的错误也无济于事。

${Application.findAllWhere((${group1}): ${group})}

Group1是从 Controller 传递的变量,而group是来自g:each的变量。这是错误。
Error 500: 
Servlet: default
URI: /archetype/application/applicationPortfolio/GroupLangTechOwn
Exception Message: No signature of method:
C__projects_Archetype_grails_app_views_application_applicationPortfolio_gsp.$() is
applicable for argument types:
(C__projects_Archetype_grails_app_views_application_applicationPortfolio_gsp$_run_closure2_closure56_closure144) values: [C__projects_Archetype_grails_app_views_application_applicationPortfolio_gsp$_run_closure2_closure56_closure144@239dbdd6] Possible solutions: is(java.lang.Object), run(), run(), any(), use([Ljava.lang.Object;), any(groovy.lang.Closure)
Caused by: Error processing GroovyPageView: No signature of method: C__projects_Archetype_grails_app_views_application_applicationPortfolio_gsp.$() is applicable for argument types: (C__projects_Archetype_grails_app_views_application_applicationPortfolio_gsp$_run_closure2_closure56_closure144) values: [C__projects_Archetype_grails_app_views_application_applicationPortfolio_gsp$_run_closure2_closure56_closure144@239dbdd6] Possible solutions: is(java.lang.Object), run(), run(), any(), use([Ljava.lang.Object;), any(groovy.lang.Closure)
Class: applicationPortfolio.gsp
At Line: [631]

谢谢!

最佳答案

尝试简化为:如Weezle指示的${Application.findAllWhere(group: group)}
但是通常最好将其放入 Controller 并返回例如:

class MyContoller {

def myAction() {
[appList: Application.findAllWhere(group: group)]
}

myAction.gsp

${appList}

<g:each var="app" in="${appList}">
${app.id} - ${app.name}
</g:each>

关于variables - 带有变量的Grails FindAllWhere,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11550246/

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