Grails 使用g:each引用另一个表中的值

Grails 使用g:each引用另一个表中的值,grails,Grails,使用Grails,我使用标记在视图中循环一个数组,但是我想在同一个循环中使用数组中的值作为对数据库另一个表中外键的引用 是否可以创建对其他表的变量引用字符串?例如: ${productId.Users.UserId} 如果我没弄错你的问题,你想做点像 //Assuming this is the list to run through your <g:each> def list = ['userId1', 'userId2', 'userId3'] 如果以上是您正在考虑的场景,

使用Grails,我使用
标记在视图中循环一个数组,但是我想在同一个循环中使用数组中的值作为对数据库另一个表中外键的引用

是否可以创建对其他表的变量引用字符串?例如:

${productId.Users.UserId}

如果我没弄错你的问题,你想做点像

//Assuming this is the list to run through your <g:each>
def list = ['userId1', 'userId2', 'userId3']
如果以上是您正在考虑的场景,那么您应该能够执行以下操作

<g:each in="${list}" var="element">
   ${model[element]}
</g:each>

//output
John Doe
Jane Doe
Jack Doe

${model[element]}
//输出
无名氏
无名氏
杰克·多伊

您能稍微扩展一下吗?从您对问题的陈述来看,productId听起来只是一个数字,而不是一个实例变量。如果是这样,我不确定如何解释${productId.Users.UserId}。
<g:each in="${list}" var="element">
   ${model[element]}
</g:each>

//output
John Doe
Jane Doe
Jack Doe