首页 > 编程知识 正文

properties内容(properties怎么用)

时间:2023-05-05 00:37:35 阅读:69546 作者:4132

Beanutils.copyProperties中的异常问题Beanutils.copyProperties提供了两种类型的异常源代码跟踪源代码分析

Beanutils.copyProperties有两个异常

Beanutils.copyProperties异常一: No origin bean specified

Beanutils.copyProperties异常No destination bean specified

在源代码跟踪中,请阅读Beanutils.copyProperties,然后内部调用beanutils bean.getinstance (.copy properties (dest,orig ) )方法

Beanutils.copyProperties ()源/** -如果属性名称相同,则将属性值从原始bean复制到目标bean。 -有关详细信息,请参见BeanUtilsBean。 -参数: dest —已修改属性的目标bean - orig —检索属性的起源bean */publicstaticvoidcopyproperties (finalobjectdest, finalobjectorig (throwsillegalaccessexception, invocationtargetexception { beanutils bean.getinstance ).copy properties } beanutils bean.copy properties ()源代码publicy final Object orig ) throws illegalaccessexception invocationtargetexception (/validateexistenceofthespecifiedbeansif (dest==null ) thrownewillegalargumentexception ) thrownewillegalargumentexception } (if ) log.isdebugenabled () log.debug ) ) beanutils.copyproperties )、) dest )、(orig ) ) ); } //Copy the properties, convertingasnecessaryif (originstanceofdynabean (finaldynaproperty [ ] orig描述符=(dynaldynaproperty ) ) orig描述符for (dynapropertyorigdescriptor 3360 orig描述符(finalstringtors ) //needtocheckisreadable (forwrapdynabean//(seejiraissue # beanutils-61 ) if ) getproperty utils (.is readable ) ) opop name ) getproperty utils (.is writeable (dest,name ) ) finalobjectvalue=((dynabean ) orig ).get ) name; 复制属性(dest,name,value ); } } else if (原始扫描引擎ofmap ) @suppresswarnings('unchecked ' ) final//mappropertiesarealwaysoftypestring, objecked ) )、mappropertiesarealwayso for (final map.entry string,object entry : propmap.entryset () ) { final strrry 获取属性实用程序(.is可写(dest,name ) )复制属性(dest,name,entry.getValue ) ); } } else/* if (origisastandardjavabean )/{finalpropertydescriptor[] orig descriptors=getproperty utils ).getpriptors for (propertydescriptororigdescriptor : orig descriptors (finalstringname if(class ).equals(name ) ) { continue; //nopointryingtosetanobject ' sclass } if (getpropertyutils (.is readable (orig,name ) getproperty utils ).isWroperty 复制属性(dest,name,value ); } catch (finalnosuchmethodexceptione )//shouldnothappen ) }源代码分析通过查看源代码来实现publicvoidcopyproperties (对象目录属性)

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。