Grails 给域动态加属性

//ExpandoMetaClass(class,boolean) class为要加属性的域
def emc = new ExpandoMetaClass(Resource.class, false )
//给Resource加hasPermission 属性
emc.hasPermission = true
emc.initialize()
//it为一个Resource的实例
it.metaClass = emc

你可能感兴趣的:(grails)