博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Atitit. Class 元数据的反射操作 api apache 工具
阅读量:4601 次
发布时间:2019-06-09

本文共 1834 字,大约阅读时间需要 6 分钟。

Atitit. Class  元数据的反射操作 api apache  工具

 

 

1 BeanUtils & PropertyUtils & MethodUtils类使用方法 短裤党 ConstructorUtils 1

2 New实例 ConstructorUtils.invokeConstructor 1

3 调用方法 MethodUtils 2

4 参考 3

 

 

 

作者:: 老哇的爪子 Attilax 艾龙,  EMAIL:1466519819@qq.com

转载请注明来源: http://blog.csdn.net/attilax

 

 

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(ometh_namenull);

catch (Exception e) {

return core.toJsonStrO88(e);

}

}

return meth;

}

调用方法 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);  

 

 

参考

 

BeanUtils & PropertyUtils & MethodUtils类使用方法 短裤党 - ITeye技术网站.html

Apache Commons BeanUtils包学习(3)-ConstructorUtils.invokeConstructor,MethodUtils.invokeMethod - Anvil的专栏 博客频道 - CSDN.NET.html

atitit.java给属性赋值方法总结and BeanUtils 1.6.1 .copyPropertybug - attilax的专栏 博客频道 - CSDN.NET.html

attilax.java 注解的本质and 使用最佳实践(3)O7 - attilax的专栏 博客频道 - CSDN.NET.html



转载于:https://www.cnblogs.com/attilax/p/5963609.html

你可能感兴趣的文章
磁盘管理综合测试
查看>>
Unity3d Shader开发(三)Pass(Pass Tags,Name,BindChannels )
查看>>
UMLet
查看>>
从父控件移除控件
查看>>
calc()制作自适应布局
查看>>
Markdown-写作必备
查看>>
关于在Java中 a!=a 值为真的解释(摘抄)
查看>>
C#串口小助手
查看>>
详解定位与定位应用
查看>>
【前端开发】 5分钟创建 Mock Server
查看>>
java 从键盘录入的三种方法
查看>>
使用jQuery和YQL,以Ajax方式加载外部内容
查看>>
pyspider 示例
查看>>
电路板工艺中的NPTH和PTH
查看>>
JNI实现JAVA和C++互相调用
查看>>
JAVA 笔记(一)
查看>>
js 循环读取 json的值
查看>>
c# 范型Dictionary实用例子
查看>>
C#实现动态页面静态化
查看>>
可选参数、命名参数、.NET的特殊类型、特性
查看>>