读书人

32 运用BeanUtils工具包操作JavaBean

发布时间: 2012-12-21 12:03:49 作者: rapoo

32 使用BeanUtils工具包操作JavaBean

?

ReflectPoint pt1 = new ReflectPoint(3,5); System.out.println(BeanUtils.getProperty(pt1, "x").getClass().getName()); BeanUtils.setProperty(pt1, "x", "9"); System.out.println(pt1.getX()); /* //java7的新特性 Map map = {name:"zxx",age:18}; BeanUtils.setProperty(map, "name", "lhm"); */ BeanUtils.setProperty(pt1, "birthday.time", "111");//支持属性的级联操作 System.out.println(BeanUtils.getProperty(pt1, "birthday.time")); PropertyUtils.setProperty(pt1, "x", 9); System.out.println(PropertyUtils.getProperty(pt1, "x").getClass().getName());?

? ? ? ? ? ? ?

?

读书人网 >编程

热点推荐