列出Bean的属性名称
/** n o w j a v a . c o m 提 供 **/ import java.beans.BeanInfo; import java.beans.Introspector; import java.beans.PropertyDescriptor; public class Main { public void m() throws Exception { try { BeanInfo bi = Introspector.getBeanInfo(MyBean.class); PropertyDescriptor[] pds = bi.getPropertyDescriptors(); for (int i = 0; i < pds.length; i++) { // Get property name String propName = pds[i].getName(); } // class, prop1, prop2, PROP3//from n o w j a v a . c o m - 时代Java } catch (java.beans.IntrospectionException e) { } } } class MyBean { // Property prop1 public String getProp1() { return null; } public void setProp1(String s) { } // Property prop2 public int getProp2() { return 0; } public void setProp2(int i) { }