beanUtils webUtils UUID使用
来源:互联网 发布:淘宝网最热销的产品 编辑:程序博客网 时间:2024/04/30 11:35
public class WebUtils {
private WebUtils(){}
// 将请求参数封装到bean
public static <T> T request2Bean(HttpServletRequest request, Class<T> clazz) {
try {
//创建请求类的对象
T bean = clazz.newInstance();
//添加id
if(request.getParameter("id") == null){
String id = UUID.randomUUID().toString();
BeanUtils.setProperty(bean,"id",id);
}
//注册转换器
ConvertUtils.register(new DateLocaleConverter(), Date.class);
// 不知道是什么样的表单 什么样的bean 不知道有哪些字段
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);
}
}
}
- beanUtils webUtils UUID使用
- WebUtils复用代码【request2Bean、UUID】
- WebUtils
- Struts1+Spring WebUtils无法使用解决办法
- beanUtils使用
- beanUtils 使用
- BeanUtils使用
- UUID使用
- WebUtils.getParametersStartingWith
- apache.commons.beanutils.BeanUtils的使用
- org.apache.commons.beanutils.BeanUtils使用示例
- BeanUtils使用笔记
- BeanUtils的使用
- BeanUtils使用笔记
- beanutils的使用
- Beanutils的使用
- Beanutils的使用
- commons - BeanUtils 使用
- Qt之QTextCodec乱谈
- DB2分区数据库的Export程序提速
- 尽可能的缓存
- 关于Latent Dirichlet Allocation及Hierarchical LDA模型的必读文章和相关代码
- 活在当下
- beanUtils webUtils UUID使用
- C# 使用Excel模板复制单元格
- Cookie&Session理解与应用
- HDU 1075 What Are You Talking About(字典树)
- 曾获资4100万美元的Color现日活跃用户仅为区区3万
- 优秀是一种习惯(转)
- 色环电阻识别方法
- 解决poi导出excel中文列宽问题
- 让win7 支持调试