beanutils.copyproperties

简介: beanutils.copyproperties

BeanUtils提供对Java反射和自省API的包装。其主要目的是利用反射机制对JavaBean的属性进行处理。我们知道,一个JavaBean通常包含了大量的属性,很多情况下,对JavaBean的处理导致大量get/set代码堆积,增加了代码长度和阅读代码的难度。

注意:属性复制,不同jar中的方法,用法不一样。


1、package org.springframework.beans;中的

    BeanUtils.copyProperties(A,B);

    是A中的值付给B

 

FinCpDocDO  finCpDoc = finCpDocService.selectByDocNo(orderNo);
FinCpDocDto finCpDto = new FinCpDocDto();
if (finCpDoc == null){
   throw new ServiceException("查无www.wityx.com网订单" + "orderNo:" + orderNo);
}
try{
   BeanUtils.copyProperties(finCpDoc, finCpDto);


2、package org.apache.commons.beanutils;(常用)

     BeanUtils.copyProperties(A,B);

     是B中的值付给A

for(OboFeeDO feeDO : oboFeeList){
    if(feeDO.getPayTime()!=null){
        ErpOboFeeDto feeDto = new ErpOboFeeDto();
        BeanUtils.copyProperties(feeDto, feeDO);
        oboFeList.add(feeDto);
    }
}


相关文章
|
6天前
|
Java Apache
BeanUtils.copyProperties详细用法
BeanUtils.copyProperties详细用法
|
6天前
|
Java Apache 开发者
beanutils.copyproperties的用法详解
beanutils.copyproperties的用法详解
|
6天前
|
前端开发 Java 数据处理
BeanUtils.copyProperties的用法
BeanUtils.copyProperties的用法
|
6天前
|
Java Apache
BeanUtils.copyProperties()用法总结
BeanUtils.copyProperties()用法总结
|
3天前
|
Java API
BeanUtils类总结
BeanUtils类总结
|
12月前
|
Java Apache 数据库
Spring的BeanUtils的copyProperties方法
项目中遇到的情况是: 文件解析完之后将文件放在一个pojo里面
99 0
|
Java API
BeanUtils.copyProperties(A,B)字段复制
BeanUtils.copyProperties(A,B)字段复制
67 0
|
Java 测试技术 Spring
为什么不推荐使用 BeanUtils ?
为什么不推荐使用 BeanUtils ?
281 0
为什么不推荐使用 BeanUtils ?