获取域类字段名称

问题描述:

我想获得一个类的字段名称,并将它存储在一个列表中。谁能帮忙?感谢。

I would like to get the field names of a class and maybe store it in a list. Can anyone help? Thanks.

您可以尝试获取域名的字段名称。

You can try this to get field names of domain class.

YourClass.declaredFields.each {
  if (!it.synthetic) {
    println it.name
  }
}