关键词不能为空

当前您在: 主页 > 高中公式大全 >

javabean对象自动赋值给另一个javabean对象

作者:高考题库网
来源:https://www.bjmy2z.cn/gaokao
2021-01-25 23:34
tags:

招标书-

2021年1月25日发(作者:季锦棠)
javabean
对象自动赋值给另一个
javabean
对象



JavaBean

from
的值自动
set

to
,省略了自己从
from

get
然后再< br>set

to







public static Object convertBean2Bean(Object from, Object to) {









try {













BeanInfo beanInfo = nInfo(ss());













PropertyDescriptor[] ps = pertyDescriptors();














for (PropertyDescriptor p : ps) {
















Method getMethod = dMethod();
















Method setMethod = teMethod();
















if (getMethod != null && setMethod != null) {




















try {























Object result = (from);























(to, result);




















} catch (Exception e) {























//
如果
from
没有此属性的
get
方法,跳过
























continue;




















}
















}













}









} catch (Exception e) {












tackTrace();









}










return to;





}






/**






*
不支持
to
继承
(to
是其他
bean
的子类
)






*/




public static Object coverBean2Bean(Object from, Object to) {









Class fClass = ss();









Class tClass = ss();









//

to
所有属性(如果有继承,父类属性拿不到)










Field[] cFields = laredFields();









try {













for (Field field : cFields) {
















String cKey = e();
















//
确定第一个字母大写

















cKey = ing(0, 1).toUpperCase() + ing(1);

招标书-


招标书-


招标书-


招标书-


招标书-


招标书-


招标书-


招标书-



本文更新与2021-01-25 23:34,由作者提供,不代表本网站立场,转载请注明出处:https://www.bjmy2z.cn/gaokao/567712.html

javabean对象自动赋值给另一个javabean对象的相关文章