国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發(fā)設計 > 正文

BeanUtils.copyProperties()的用法;

2019-11-11 01:42:52
字體:
供稿:網(wǎng)友

雖然目前已經(jīng)有很多文章介紹此方法的用法,但是既然自己遇到了。 還是記錄一下吧。

導包:import org.sPRingframework.beans.BeanUtils;

源代碼的介紹:

/** * Copy the property values of the given source bean into the target bean. * <p>Note: The source and target classes do not have to match or even be derived * from each other, as long as the properties match. Any bean properties that the * source bean exposes but the target bean does not will silently be ignored. * <p>This is just a convenience method. For more complex transfer needs, * consider using a full BeanWrapper. * @param source the source bean * @param target the target bean * @throws BeansException if the copying failed * @see BeanWrapper */ public static void copyProperties(Object source, Object target) throws BeansException { copyProperties(source, target, null, (String[]) null); }

介紹: BeanUtils.copyProperties(bean, detailBean); //bean 給detailBean 賦值 此方法是將前面的bean 給detailBean賦值。

詳細介紹: BorrowInfoBean bean=new BorrowInfoBean(); bean=this.getBorrowInfo(999); //此句意思就是查詢bean的信息;

BorrowInfoBean detailBean=new BorrowInfoBean (); //新的bean

BeanUtils.copyProperties(bean, detailBean); //bean 給detailBean 賦值

(未驗證,從別的博客看到)要注意一點,java.util.Date是不被支持的,而它的子類java.sql.Date是被支持的。因此如果對象包含時間類型的屬性,且希望被轉(zhuǎn)換的時候,一定要使用java.sql.Date類型。否則在轉(zhuǎn)換時會提示argument mistype異常。


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 周宁县| 高陵县| 花莲市| 新余市| 京山县| 恩平市| 漳平市| 罗城| 志丹县| 衡阳市| 晋宁县| 恩平市| 黄梅县| 玉山县| 赤水市| 阿合奇县| 哈尔滨市| 阳新县| 湛江市| 寻乌县| 师宗县| 平谷区| 绵竹市| 大同市| 黄冈市| 商南县| 防城港市| 屯留县| 琼中| 郓城县| 同心县| 蕉岭县| 舞阳县| 厦门市| 苗栗市| 丰台区| 东城区| 菏泽市| 高安市| 张家界市| 东乡|