工作上遇到个问题,顺便解决了,希望对大家有帮助
package com.zuidaima.util;
public static void main(String[] args) throws ClassNotFoundException, IllegalArgumentException, IllegalAccessException, InstantiationException {
Class> obj = Class.forName("com.roiland.oa.persistence.gen.model.Funnel");
Funnel funnel=new Funnel();//MODEL
Field[] f =obj.getDeclaredFields();
for (Field field :f) {
field.setAccessible(true);
System.out.println(field.getName()+":"+field.get(obj.newInstance())); //get titleName:value
}
}