import org.apache.commons.beanutils.PropertyUtilsBean;
import java.beans.PropertyDescriptor;
public static void getPropertyKeyValue(Object obj) {
try {
PropertyUtilsBean propertyUtilsBean = new PropertyUtilsBean();
PropertyDescriptor[] descriptors = propertyUtilsBean.getPropertyDescriptors(obj);
for (int i = 0; i < descriptors.length; i++) {
String name = descriptors[i].getName();
if (!"class".equals(name)) {
System.out.println(name + ":" + propertyUtilsBean.getSimpleProperty(obj, name));
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
GlobalParamters globalParamters = new GlobalParamters();
getPropertyKeyValue(globalParamters);
}