把一個物件的屬性值拷貝到另一個物件上去
阿新 • • 發佈:2019-02-12
public static void copyProperties(Object dest,Object src){
try{
ConvertUtils.register(new DateConverter(null),java.util.Date.class);
ConvertUtils.register(new SqlTimestampConverter(null), Timestamp.class);
BeanUtils.copyProperties(dest,src);
}catch (Exception e){
logger.error("copyProperties {}",e);
}
try{
ConvertUtils.register(new DateConverter(null),java.util.Date.class);
ConvertUtils.register(new SqlTimestampConverter(null), Timestamp.class);
BeanUtils.copyProperties(dest,src);
}catch (Exception e){
logger.error("copyProperties {}",e);
}
}
org.apache.commons.beanutils.ConvertUtils
org.apache.commons.beanutils.BeanUtils
public static void copyProperties(Object dest, Object orig)
throws IllegalAccessException, InvocationTargetException {
BeanUtilsBean.getInstance().copyProperties(dest, orig);
}