使用springmvc利用baseController自动收集请求参数

来源:互联网 发布:淘宝怎样提升信誉 编辑:程序博客网 时间:2024/05/16 17:25
public abstract class BaseController中添加以下方法
/** * 获取请求属性封装为Map类型 * @param request * @return */protected HashMap<String, Object> getRequestMapSingle(HttpServletRequest request) {HashMap<String, Object> conditions = new HashMap<String, Object>();Map map = request.getParameterMap();for (Object o : map.keySet()) {String key = (String) o;conditions.put(key, ((String[]) map.get(key))[0]);}return conditions;}

在普通Controller中public class XXController extends BaseController {

在方法中调用即可:HashMap<String, Object> parameters = getRequestMapSingle(request);

}


还请各位大神多多指导!不喜勿喷!!!

1 1
原创粉丝点击