/**
* 根据request获取请求的用户参数
* @return
* @return
*/
protected <T> T getParamConvertEntity(Class cls) {
Object obj = null;
try {
obj = cls.newInstance();
Map paramMap = new HashMap();
paramMap.putAll(request.getParameterMap());
//设置用户ID
paramMap.put("userId", getUserId());
BeanUtils.populate(obj, paramMap);
log.debug("请求的用户信息为:"+JSONObject.fromObject(obj).toString());
} catch (Exception ex) {
log.error("用户请求信息转换错误" + ex.getMessage(), ex);
}
return (T) obj;
}
2, 获取request参数
orderInfo 实体类
BeanUtils.populate(orderInfo, request.getParameterMap());
时间: 2024-10-19 05:24:21