@@ -0,0 +1,1291 @@
+package com.haozileung.infra.utils;%0D%0A%0D%0Aimport java.lang.reflect.InvocationTargetException;%0D%0Aimport java.util.Date;%0D%0Aimport java.util.Enumeration;%0D%0Aimport java.util.HashMap;%0D%0A%0D%0Aimport javax.servlet.http.HttpServletRequest;%0D%0A%0D%0Aimport org.apache.commons.beanutils.BeanUtils;%0D%0Aimport org.apache.commons.beanutils.ConvertUtils;%0D%0Aimport org.apache.commons.beanutils.converters.DateConverter;%0D%0A%0D%0Aimport com.google.common.collect.Maps;%0D%0A%0D%0Apublic class RequestBeanUtils %7B%0D%0A%0D%0A%09public %3CT%3E T getBean(HttpServletRequest request, Class%3CT%3E clazz,%0D%0A%09%09%09String dateFormat) %7B%0D%0A%09%09HashMap%3CString, Object%3E map = Maps.newHashMap();%0D%0A%09%09Enumeration%3CString%3E names = request.getParameterNames();%0D%0A%09%09while (names.hasMoreElements()) %7B%0D%0A%09%09%09String name = (String) names.nextElement();%0D%0A%09%09%09map.put(name, request.getParameterValues(name));%0D%0A%09%09%7D%0D%0A%09%09DateConverter dateConverter = new DateConverter();%0D%0A%09%09if (dateFormat == null) %7B%0D%0A%09%09%09dateFormat = %22yyyy-MM-dd%22;%0D%0A%09%09%7D%0D%0A%09%09dateConverter.setPattern(dateFormat);%0D%0A%09%09ConvertUtils.register(dateConverter, Date.class);%0D%0A%09%09T bean = null;%0D%0A%09%09try %7B%0D%0A%09%09%09bean = clazz.newInstance();%0D%0A%09%09%09BeanUtils.populate(bean, map);%0D%0A%09%09%7D catch (InstantiationException %7C IllegalAccessException e1) %7B%0D%0A%09%09%09bean = null;%0D%0A%09%09%7D catch (InvocationTargetException e) %7B%0D%0A%09%09%09bean = null;%0D%0A%09%09%7D%0D%0A%09%09return bean;%0D%0A%09%7D%0D%0A%7D%0D%0A

add utils