1

grails では、Child と呼ばれるドメインのすべてのインスタンスをその許可されたユーザーに出力しようとしています。

私は以下を使用しています:

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

各ユーザーは複数の子 (子) を持つことができ、現在ログインしているユーザーの子を一覧表示したいと考えています。ログインなどにSpring Source Security Coreプラグインを使用しています。

これは私の例外です:

クラス: groovy.lang.MissingPropertyException メッセージ: そのようなプロパティはありません: クラスの名: com.fyp.timeline.Child 可能な解決策: 名、姓

何か案は?

4

1 に答える 1

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

userは、ログインしているユーザーのインスタンスです。

User{
    static hasMany=[children:Child]
}
于 2012-08-21T19:40:26.170 に答える