我试图在grails gsp中传递一个findAllWhere传递2个变量:一个是属性,一个是我希望该属性相等的值。 I.E(作者:马克吐温)我无法弄清楚我收到的语法和错误没有帮助。
${Application.findAllWhere((${group1}): ${group})}
Group1是从控制器传递的变量,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]
谢谢!
答案 0 :(得分:3)
尝试简化为:${Application.findAllWhere(group: group)}
,如Weezle所示
但通常最好把它放在控制器中并返回例如:
class MyContoller {
def myAction() {
[appList: Application.findAllWhere(group: group)]
}
myAction.gsp
${appList}
<g:each var="app" in="${appList}">
${app.id} - ${app.name}
</g:each>