我有一个类:
class Category {
String name
SortedSet items
static hasMany = [items:Item]
}
在 Controller 内部,我将类别呈现为 XML(转换器):
def getCategory = {
render Category.read(1) as XML
}
但我想从渲染中排除项目。
我能怎么做 ?
谢谢
最佳答案
您可以简单地返回 Map
仅包含您要包含的属性:
def getCategory = {
def category = Category.read(1)
render [ id: category.id, name: category.name ] as XML
}
关于ajax - 如何从 Grails 中呈现的 XML 中排除参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2833240/