BeanUtilities 使用

报错:

  java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
  java.lang.NoClassDefFoundError: org/apache/commons/collections/FastHashMap

依赖包:

  https://mvnrepository.com/artifact/commons-beanutils/commons-beanutils/1.9.3

  https://mvnrepository.com/artifact/commons-collections/commons-collections/3.2.2

  https://mvnrepository.com/artifact/commons-logging/commons-logging/1.2

  

 

package coreservlets.beans;

import java.util.Arrays;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.beanutils.BeanUtils;

public class BeanUtilities {
     // 重载 Overloading
	public static void populateBean(Object formBean, HttpServletRequest request) {
		populateBean(formBean, request.getParameterMap());
	}
	// 重载 Overloading
	public static void populateBean(Object bean, Map propertyMap) {	
		try {
			BeanUtils.populate(bean, propertyMap);			
		} catch (Exception e) {
			System.out.println("populate exception");
		}
	}
}

  

  

 

posted @ 2019-05-23 07:01  mapleflow  阅读(175)  评论(0编辑  收藏  举报