And using a packaging extract data BeanUtils

Copyright: https://blog.csdn.net/No_mingzi/article/details/90711446
public class Utils {
	/**
	 * 降低代码的耦合度,只需要在方法的参数上使用基本数据类型,或javaSE的类库
	 * 
	 * @param request
	 * @param bean
	 */
	public static <T> T copyParamToBean(Map map , T bean) {
		try {
			BeanUtils.populate(bean, map);
			System.out.println("注入值之后:" + bean);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return bean;
	}
	
}

BeanUtils tools can be injected into the certain values ​​disposable object Bean

: BeanUtil using procedure
1, introduced jar package
Commons-BeanUtils-1.8.0.jar
Commons the logging-1.1.1.jar-
method 2, the call BeanUtils

EL expressions to go when the value is getXxx method (read method)
BeanUtils underlying value at the time of injection, setXxx method go (write method)

Guess you like

Origin blog.csdn.net/No_mingzi/article/details/90711446