0

我正在尝试在传递 2 个变量的 grails gsp 中执行 findAllWhere:一个是属性,一个是我希望该属性相等的值。IE(作者:Mark Twain)我无法弄清楚语法,我收到的错误也无济于事。

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

Group1 是从控制器传递的变量,group 是来自 ag: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] 

谢谢!

4

1 回答 1

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>
于 2012-07-18T23:03:04.570 回答