Field[] field = behavior.getClass().getDeclaredFields();
for (int i = 0; i < field.length; i++) {
String name = field[i].getName();
name = name.substring(0, 1).toUpperCase() + name.substring(1);//找到首位改成大写形式
String type = field[i].getGenericType().toString();//字段类型
if (type.equals("class java.lang.String")) {
Method m;
String value;
try {
m = behavior.getClass().getMethod("get" + name);
value = (String) m.invoke(behavior);
if (value.equals("x")) {//value是获取到的值
mapdata.put("behavior", name);//name是字段名
}
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (SecurityException e) {
e.printStackTrace();
}

}

最新文章

  1. guava学习--hashing
  2. Javascript基础系列之(二)变量
  3. Office2010 pro附+激活工具
  4. JS闭包(转载加整理)
  5. lintcode :nth to Last Node In List 链表倒数第n个节点
  6. Lua学习笔记(二):基本语法
  7. 软件工程 --- Pair Project: Elevator Scheduler [电梯调度算法的实现和测试]
  8. webbroswer 后台注入脚本 的方法
  9. Java 8 表示两个时间点距离
  10. 华为C语言编程规范笔记1
  11. 在 Visual Studio 中使用 IntelliTrace 快照功能
  12. Element.scrollIntoView()
  13. 什么是联机分析处理(OLAP)
  14. C++ Primer 笔记——基本内置类型
  15. RF射频技术的原理
  16. JS浏览器BOM
  17. bzoj 5334 数学计算
  18. HDU 4355——Party All the Time——————【三分求最小和】
  19. [arc063]F.すぬけ君の塗り絵2
  20. SpringBoot快速入门01--环境搭建

热门文章

  1. 【译】Rust中的array、vector和slice
  2. React react-redux props或state更新视图无法重新渲染问题
  3. Spring Boot API 统一返回格式封装
  4. Ros中创建msg和srv遇到的问题
  5. c#分割习题
  6. Prometheus监控告警浅析
  7. layuiu按钮
  8. 手机运行Linux系统,可以办公,可以上网,太爽了!
  9. npm pm2
  10. IP/TCP/UDP checsum