class why{
def name ="why"
def age = 15
def run() {
println 'Groovy world!'
}
public static void main(String[] args)
{
def t = new why()
t.run()
def mapProperties = t.getProperties()
mapProperties.remove('class')//默认有自带class属性,移除减少数据传输量
println(mapProperties)
}
}
因工作中需要把从数据库获取查询出来的实体属性逐个取出,然后存入map,在发往前端,逐个遍历属性过于繁琐,故查找了下groovy 提供的方法来实现。就此记录一下。
最后
以上就是忧虑电脑最近收集整理的关于如何把groovy对象的全部属性取出,无需逐个访问的全部内容,更多相关如何把groovy对象内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复