@Test public void testCommonUitls() throws Exception{ Employee em = new Employee(); //String name; String[] ss; Map map; List list; BeanUtils.setProperty(em,"name","liukaiyi"); //String set BeanUtils.setProperty(em,"ss",new String[]{"1","2","3"}); //String[] set BeanUtils.setProperty(em,"ss[2]","google"); //String[2] set BeanUtils.setProperty(em,"map",new HashMap()); //Map set BeanUtils.setProperty(em,"map(key)","value"); //Map.put(Key,Value) BeanUtils.setProperty(em,"list",new ArrayList( Arrays.asList( new Object[20] ) )); //List有点特别 BeanUtils.setProperty(em,"list[0]","list"); //不可以直接添加??? BeanUtils.setProperty(em,"avg","23"); //int set System.out.println( BeanUtils.getProperty(em,"name") ); //get value :liukaiyi System.out.println( BeanUtils.getProperty(em,"ss[2]") ); //get value:google System.out.println( BeanUtils.getProperty(em,"map(key)") );//get value:value System.out.println( BeanUtils.getProperty(em,"list[0].class") ); // 取的是 ==list.get(0).getClass() System.out.println( BeanUtils.getProperty(em,"avg") ); }