日期:2014-05-18 浏览次数:20669 次
public static <T> T request2bean(HttpServletRequest request,Class<T> beanClass)
{
try
{
T bean = beanClass.newInstance();
Enumeration e = request.getParameterNames();
while(e.hasMoreElements())
{
String name = (String) e.nextElement();
String value = request.getParameter(name);
BeanUtils.setProperty(bean, name, value);
}
return bean;
}
catch (Exception e)
{
throw new RuntimeException(e);
}
}