public void copyPropertys(Object src,Maptarget){ if(null != src && null != target){ try { BeanInfo beanInfo = Introspector.getBeanInfo(src.getClass()); PropertyDescriptor[] descs = beanInfo.getPropertyDescriptors(); for(PropertyDescriptor property : descs){ String key = property.getName(); if(!key.equals("class")){ Method getter = property.getReadMethod(); Object value = getter.invoke(src); if(null != value){ target.put(key, value); } } } } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IntrospectionException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } } }