I have an object called Termin, when I print it I get the following values
println(Termin)
#1 User123 20.00 Home
How can I print the properties field names like this for example:
user_id user_name time location
您应该能够:
def propNames = grailsApplication.getDomainClass( 'Termin' ).properties*.name
我使用下面的代码来获取域的属性:
Shop.class.getDeclaredFields().grep { !it.synthetic && !Modifier.isStatic(it.getModifiers())}.name
names and value...
object.properties.each { k,v->
println "${k} | ${v}"
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.