简体   繁体   English

Grails g:每个标签

[英]Grails g:each tag

In grails I am trying to get every instance of a domain called Child to be printed out for that authorized user. 在grails中,我试图为该授权用户打印出名为Child的域的每个实例。

I am using the following: 我正在使用以下内容:

 <g:each var="child" in="${Child}">
    <p>Name: ${child.firstname}</p>
    <p>Surname: ${child.lastname}</p>
 </g:each>

Each user can have several children (Child) and I want it to list the children for the currently logged in user. 每个用户可以有几个孩子(孩子),我希望它列出当前登录用户的孩子。 I am using spring source security core plugin for my login etc. 我正在使用Spring Source Security Core插件进行登录等。

This is my exception: 这是我的例外:

Class : groovy.lang.MissingPropertyException Message : No such property: firstname for class: com.fyp.timeline.Child Possible solutions: firstname, lastname 类:groovy.lang.MissingPropertyException消息:无此类属性:类的名字:com.fyp.timeline.Child可能的解决方案:名字,姓氏

Any ideas? 有任何想法吗?

<g:each var="child" in="${user.children}">
   <p>Name: ${child.firstname}</p>
   <p>Surname: ${child.lastname}</p>
</g:each>

user is an instance of logged in user where 用户是已登录用户的实例,其中

User{
    static hasMany=[children:Child]
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM