chenqb 发表于 2017-1-7 13:18:49

初用apache.commons.beanutils.BeanUtils

  该class提供了一系列的静态方法操作业已存在的符合JavaBean规范定义的Java Class.这里强调的JavaBean规范,简单来说就是一个Java Class通过一系列getter和setter的方法向外界展示其内在的成员变量(属性).通过BeanUtils的静态方法,我们可以:

[*]复制一个JavaBean的实例--BeanUtils.cloneBean();
[*]在一个JavaBean的两个实例之间复制属性--BeanUtils.copyProperties(),BeanUtils.copyProperty();
[*]为一个JavaBean的实例设置成员变量(属性)值--BeanUtils.populate(),BeanUtils.setProperty();
[*]从一个一个JavaBean的实例中读取成员变量(属性)的值--BeanUtils.getArrayProperty(),BeanUtils.getIndexedProperty(),BeanUtils.getMappedProperty(),BeanUtils.getNestedProperty(),BeanUtils.getSimpleProperty(),BeanUtils.getProperty(),BeanUtils.describe();
  总的来看BeanUtils类提供了两大类的功能:读,写成员变量.
页: [1]
查看完整版本: 初用apache.commons.beanutils.BeanUtils