您的位置:首页 > 产品设计 > UI/UE

java 获取request中的参数,并将所有参数封装成map 工具le

2016-09-22 15:30 477 查看
public static Map getRequestParamMap(HttpServletRequest request)
{
Map map = new HashMap();
//得到枚举类型的参数名称,参数名称若有重复的只能得到第一个
Enumeration enums = request.getParameterNames();
while (enums.hasMoreElements())
{
String paramName = (String) enums.nextElement();
String paramValue = request.getParameter(paramName);

//形成键值对应的map
map.put(paramName, paramValue);
}
return map;
}

使用:Map paramMap=RequestUtils.getRequestParamMap(request);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息