引入包

     <dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.9.</version>
</dependency>

main执行

package com.gwzx.pay;

import java.util.Map;
import java.util.Map.Entry; import org.apache.commons.beanutils.BeanUtils; public class S { public static void main(String[] args) {
// TODO Auto-generated method stub
try {
// 1: 属性复制
Student2 s1 = new Student2(, "张三", , Boolean.FALSE);
Student2 s2 = new Student2();
BeanUtils.copyProperties(s2, s1);
System.out.println("1:" + s2.getName()); // 2: 属性放入map
Map<String, String> map = BeanUtils.describe(s2);
for (Entry<String, String> o : map.entrySet()) {
System.out.println(o.getKey() + "=" + o.getValue());
}
map.clear();
// 不会放入s2
map.put("aa", "bb");
// 覆盖s2
map.put("id", "");
map.put("bool", "true"); // 3: Map值 动态放入s2对象中
BeanUtils.populate(s2, map);
System.out.println(s2.toString()); } catch (Exception e) {
// TODO: handle exception
}
} }

最新文章

  1. 在SQLSERVER2008中建立数据库复制碰到的问题
  2. android 入门-布局
  3. 基于HTML5的电信网管3D机房监控应用
  4. 开发中遇到的angularJs的小问题
  5. 小公司生存,一般活过第一年,就能撑3年(读书笔记:成败关键,关键是你是否拥有现金流客户)good
  6. 考察printf函数返回值
  7. was性能调优
  8. 工作中常用Git指令操作
  9. CODEFORCES ROUND #761 ANALYSES BY TEAM:RED &amp; BLACK
  10. [cb]ScriptableWizard 创建向导
  11. Jmeter接口测试参数化实例图文示例
  12. 不要再混淆js的substring和substr了!(附js所有字符串方法)
  13. 在Spring Boot中使用 @ConfigurationProperties 注解, @EnableConfigurationProperties
  14. Intellij IDEA 文件修改提示星号
  15. Win10年度更新开发必备:VS2015 Update 2正式版下载汇总
  16. SpringBoot系列十二:SpringBoot整合 Shiro
  17. 熟悉使用ConfigParser库读写配置文件
  18. nodejs(五)同步异步--USING SETTIMEOUT INSTEAD OF SETINTERVAL TO FORCE SERIALIZATION
  19. centos下安装必要组件(相当于apt-get install install build-essential)
  20. Spring Boot与Mybatis 借助Fastjson快速完成数据解析入库

热门文章

  1. python函数 传参的多种方式 解读
  2. 服务容错保护断路器Hystrix之六:服务熔断和服务降级
  3. ha环境下重新格式化hdfs报错
  4. Css学习(4)
  5. 把SAS批提交添加到鼠标右键
  6. 用户授权的Sql脚本
  7. Delphi 解决Utf8ToAnsi和Utf8DeCode转换编码为空的问题
  8. (转)C#.NET WINFORM应用程序中控制应用程序只启动一次
  9. KVM总结-KVM性能优化之网络性能优化
  10. solr学习(六):使用自定义int/long类型主键