Commons-BeanUtils 是Apache commons子项目中的一个软件包,其主要目的是利用反射机制对JavaBean的属性进行处理。
示例代码:
Employee employee = ...; String firstName = (String) PropertyUtils.getSimpleProperty(employee, "firstName"); String lastName = (String) PropertyUtils.getSimpleProperty(employee, "lastName"); ... maNipulate the values ... PropertyUtils.setSimpleProperty(employee, "firstName", firstName); PropertyUtils.setSimpleProperty(employee, "lastName", lastName);
发布于 2016-09-27 08:29:20 | 176 次阅读