方法一
//bean装换成map
public static Map<?, ?> objectToMap2(Object obj) {  
         if(obj == null)  
             return null;   
         return new org.apache.commons.beanutils.BeanMap(obj);  
     }  
    方法二
//bean装换成map
    public static Map<String, Object> objectToMap(Object obj)  {
         Map<String, Object> map = new HashMap<String, Object>();
         try{
             if (obj == null)
                 return map;
             BeanInfo beanInfo = Introspector.getBeanInfo(obj.getClass());
             PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
             for (PropertyDescriptor property : propertyDescriptors) {
                 String key = property.getName();
                 if (key.compareToIgnoreCase("class") == 0) {
                     continue;
                 }
                 Method getter = property.getReadMethod();
                // System.out.println("key:" + key + ",getter:" + getter);
                 Object value = getter != null ? getter.invoke(obj) : null;
                 map.put(key, value);
             }
         }catch(Exception e){
             e.printStackTrace();
         }
         return map;
     }
//map装换成bean
public static Object mapToObject(Map<String, Object> map, Object bean) throws Exception {    
         if (map == null)  
             return null;  
         Object obj = bean.getClass().newInstance();  
         org.apache.commons.beanutils.BeanUtils.populate(obj, map);
    
         return obj;  
     }