0

我有一个域类

class Something {
    String name
    String email
    List<String> friends = []
}

在域类本身中,我有一个填充朋友列表的Something 对象的方法。但由于某种原因,我无法保留此列表。并且在浏览远离与域修改操作相关的 gsp 时它会变为 null。

关于为什么会发生这种情况的任何建议?

4

1 回答 1

2

我认为您需要将您的域编写为:

class Something {
    String name
    String email
    List friends
    static hasMany = [ friends: String ]
}
于 2013-10-30T12:13:23.177 回答