Atitit. Class 元数据的反射操作 api apache 工具
Atitit. Class 元数据的反射操作 api apache 工具
1 BeanUtils & PropertyUtils & MethodUtils类使用方法 - 短裤党 ConstructorUtils1
2 New实例 ConstructorUtils.invokeConstructor1
1 BeanUtils & PropertyUtils & MethodUtils类使用方法 - 短裤党 ConstructorUtils
作者:: 老哇的爪子 Attilax 艾龙, EMAIL:1466519819@qq.com
转载请注明来源: http://www.cnblogs.com/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技术网站.html
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
相关文章
- Apache Ant安装与配置
- linux apache安装与配置_Apache配置
- Apache knox_apache发生服务特定错误1
- apache的安装教程详解_怎么安装apache
- 【错误记录】Groovy 报错 ( Execution failed for task ‘:compileGroovy‘. > org/apache/tools/ant/taskdefs/Java )
- apache-incubator-streampark源码编译本地运行
- Apache Doris Join 优化原理详解
- 使用MySQL语句来查询Apache服务器日志的方法
- Apache的Mina简单实例详解编程语言
- apache commons collections CollectionUtils工具类简单使用详解编程语言
- apache用Linux服务器架设QQ五笔输入法服务:基于Apache技术(qq五笔linux)
- org.apache.commons.beanutils.ConversionException: No value specified详解编程语言
- 结合开发,推动进步: Apache与MySQL的协作(apache和mysql)
- 搭配Apache MySQL:超强联手服务器助力(apache和mysql)
- Apache Tomcat 7.0.54现已可供下载
- 在 Ubuntu 中安装 Apache、MySQL、PHP(LAMP)套件
- 【漏洞预警】Apache Struts2 曝任意代码执行漏洞 (S2-045,CVE-2017-5638)
- windows配置Apache+PHP+MySQL动态网站环境
- 使用Apache和MSSQL构建强大的数据库系统(apache mssql)
- Apache与MySQL的完美融合开启精彩程序之旅(apache加mysql)
- Apache与Tomcat服务器整合的基本配置方法及概要说明
- 如何在Ubuntu下启动Apache的Rewrite功能
- win8下XAMPP中Apache模块无效(apache无法打开)的解决方法
- apache密码生成工具htpasswd使用详解
- Apache、Nginx下FontAwesome在Firefox中不显示问题解决方法
- Linux+php+apache+oracle环境搭建之CentOS下安装Apache