读书人

利用BeanUtils工具种给JavaBean设置和

发布时间: 2012-12-22 12:05:06 作者: rapoo

利用BeanUtils工具类给JavaBean设置和取值

import org.apache.commons.beanutils.BeanUtils;import org.apache.commons.beanutils.PropertyUtils;public class BeanutilTest {public static void main(String[] args) throws Exception{Point p = new Point();BeanUtils.setProperty(p, "x", 7);System.out.println(BeanUtils.getProperty(p, "x"));BeanUtils.setProperty(p, "birthday.time", "2011101");System.out.println(BeanUtils.getProperty(p, "birthday.time"));PropertyUtils.setProperty(p, "x", 9);System.out.println(PropertyUtils.getProperty(p, "x"));}}
?

读书人网 >编程

热点推荐