Package reflect; import Java. lang. reflect. field; import Java. lang. reflect. invocationtargetexception; import Java. util. date; import Java. util. hashmap; import Java. util. map; import Org. apache. commons. beanutils. beanutils; import Org. apache. commons. beanutils. propertyutils; public class beanutilstest {public static void printobj (Object O) throws illegalargumentexception, illegalaccessexception {for (field F:. class. getdeclaredfields () {// getfields () cannot obtain the private variable F. setaccessible (true); // brute force access to private system. out. println (F. get (O) ;}} public static void properties (Object O) throws illegalaccessexception, invocationtargetexception, nosuchmethodexception {beanutils. setproperty (O, "birthday. year "," 113 "); // class attribute cascade settings // age is int type. Here, the string value is automatically converted to int, which is suitable for web projects. // If propertyutils is used. setproperty will not automatically convert beanutils. setproperty (O, "Age", "27"); system. out. println (beanutils. getproperty (O, "Birthday"); system. out. println (beanutils. getproperty (O, "Age");} public static void convertobjtomap (Object O) throws illegalaccessexception, invocationtargetexception, nosuchmethodexception {map = beanutils. describe (o); For (Object key: map. keyset () {system. out. println (Key + ":" + map. get (key) ;}} public static void putmapintoobj (Object O) throws illegalaccessexception, invocationtargetexception {Map <string, Object> properties = new hashmap <string, Object> (); properties. put ("name", "Rain"); properties. put ("Age", "24"); properties. put ("Birthday", new date (); beanutils. populate (O, properties); // import map data to objprintobj (o); // print} public static void main (string [] ARGs) throws illegalaccessexception, invocationtargetexception, nosuchmethodexception {A = new A (); beanutilstest. printobj (a); // beanutilstest. properties (a); // beanutilstest. convertobjtomap (a); // beanutilstest. putmapintoobj ();}}