Atitit. Class  元数据的反射操作 api apache  工具
2015-09-07 17:58
561 查看
Atitit. Class 元数据的反射操作 api apache 工具
1 BeanUtils & PropertyUtils & MethodUtils类使用方法 - 短裤党 ConstructorUtils
1
2 New实例 ConstructorUtils.invokeConstructor
1
3 调用方法 MethodUtils
2
4 参考
3
转载请注明来源: http://blog.csdn.net/attilax
String meth = req.getParameter("method");
Handler hd = (Handler) mp.get(meth);
if (hd != null) {
try {
return (String) hd.handleReq(req);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
return e.getMessage();
}
}
if (hd == null) {
String classname = refx.getClassName(meth);
String meth_name = refx.getMethodName(meth);
Object o;
try {
o = ConstructorUtils.invokeConstructor(
Class.forName(classname), null);
MethodUtils.invokeMethod(o, meth_name, null);
} catch (Exception e) {
return core.toJsonStrO88(e);
}
}
return meth;
}
2. System.out.println( MethodUtils.invokeMethod(entity, "haha", null) );
3.
4. //通过MethodUtils的invokeMethod方法,执行指定的entity中的方法(1参的情况)
5. MethodUtils.invokeMethod(entity, "sayHelle", "心梦帆影");
6.
7. //通过MethodUtils的invokeMethod方法,执行指定的entity中的方法(多参的情况)
8. Object[] params = new Object[]{new Integer(10),new Integer(12)};
9. String msg = (String)MethodUtils.invokeMethod(entity, "countAges", params);
10. System.out.println(msg);
Apache Commons BeanUtils包学习(3)-ConstructorUtils.invokeConstructor,MethodUtils.invokeMethod - Anvil的专栏 - 博客频道 - CSDN.NET.html
atitit.java给属性赋值方法总结and BeanUtils 1.6.1 .copyProperty的bug - attilax的专栏 - 博客频道 - CSDN.NET.html
attilax.java 注解的本质and 使用最佳实践(3)O7 - attilax的专栏 - 博客频道 - CSDN.NET.html
1 BeanUtils & PropertyUtils & MethodUtils类使用方法 - 短裤党 ConstructorUtils
1
2 New实例 ConstructorUtils.invokeConstructor
1
3 调用方法 MethodUtils
2
4 参考
3
1 BeanUtils & PropertyUtils & MethodUtils类使用方法 - 短裤党 ConstructorUtils
作者:: 老哇的爪子 Attilax 艾龙, EMAIL:1466519819@qq.com转载请注明来源: http://blog.csdn.net/attilax
2 New实例 ConstructorUtils.invokeConstructor
private String exe(HttpServletRequest req) {String meth = req.getParameter("method");
Handler hd = (Handler) mp.get(meth);
if (hd != null) {
try {
return (String) hd.handleReq(req);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
return e.getMessage();
}
}
if (hd == null) {
String classname = refx.getClassName(meth);
String meth_name = refx.getMethodName(meth);
Object o;
try {
o = ConstructorUtils.invokeConstructor(
Class.forName(classname), null);
MethodUtils.invokeMethod(o, meth_name, null);
} catch (Exception e) {
return core.toJsonStrO88(e);
}
}
return meth;
}
3 调用方法 MethodUtils
1. //通过MethodUtils的invokeMethod方法,执行指定的entity中的方法(无参的情况)2. System.out.println( MethodUtils.invokeMethod(entity, "haha", null) );
3.
4. //通过MethodUtils的invokeMethod方法,执行指定的entity中的方法(1参的情况)
5. MethodUtils.invokeMethod(entity, "sayHelle", "心梦帆影");
6.
7. //通过MethodUtils的invokeMethod方法,执行指定的entity中的方法(多参的情况)
8. Object[] params = new Object[]{new Integer(10),new Integer(12)};
9. String msg = (String)MethodUtils.invokeMethod(entity, "countAges", params);
10. System.out.println(msg);
4 参考
BeanUtils & PropertyUtils & MethodUtils类使用方法 - 短裤党 - ITeye技术网站.htmlApache Commons BeanUtils包学习(3)-ConstructorUtils.invokeConstructor,MethodUtils.invokeMethod - Anvil的专栏 - 博客频道 - CSDN.NET.html
atitit.java给属性赋值方法总结and BeanUtils 1.6.1 .copyProperty的bug - attilax的专栏 - 博客频道 - CSDN.NET.html
attilax.java 注解的本质and 使用最佳实践(3)O7 - attilax的专栏 - 博客频道 - CSDN.NET.html
相关文章推荐
- Atitit. Class 元数据的反射操作 api apache 工具
- Atitit. Class 元数据的反射操作 api apache 工具
- zabbix监控apache
- Apache设置局域网内ip地址访问
- Ubuntu14.04 LTS下修改apache2默认端口
- [转]Windows7 64bit下配置Apache+PHP+MySQL
- apache+php安装(centos6.5)
- 安装xampp后apache不能启动解决方法
- Apache windows安装
- Apache Camel中的recipientList和routingSlip的区别?
- org.apache.commons.lang下的工具类
- [Centos]编译安装apache 2.4
- apache maven-release-plugin 版本管理方式
- php+apache+mysql环境配置
- apache common-io.jar FileUtils
- 零成本实现Web性能测试:基于Apache JMeter
- Apache Camel的multicast简单示例
- win7使用eclipse连接hadoop集群,运行mapreduce报错之:org.apache.hadoop.security.AccessControlException
- Apache Camel的sample的简单示例
- apache网站日志分析