第一种:
private Map<String,Object> mapParameters(HttpServletRequest request) { //封装查询条件参数 Map<String, Object> map = new HashMap<String, Object>(); Enumeration enu = request.getParameterNames(); while (enu.hasMoreElements()) { String key = (String) enu.nextElement(); String value = request.getParameter(key); map.put(key, value); } return map; }
第二种:
Map map=request.getParameterMap(); Set keSet=map.entrySet(); for(Iterator itr=keSet.iterator();itr.hasNext();){ Map.Entry me=(Map.Entry)itr.next(); Object ok=me.getKey(); Object ov=me.getValue(); String[] value=new String[1]; if(ov instanceof String[]){ value=(String[])ov; }else{ value[0]=ov.toString(); } for(int k=0;k<value.length;k++){ System.out.println(ok+"="+value[k]); } }