Java获取request传递的所有参数

// 增加查询日志  获取所有查询的参数名称和值 json格式存储
        Map map = new HashMap();
        Enumeration paramNames = request.getParameterNames();
        while (paramNames.hasMoreElements()) {
            String paramName = (String) paramNames.nextElement();
            String[] paramValues = request.getParameterValues(paramName);
            if (paramValues.length == 1) {
                String paramValue = paramValues[0];
                if (paramValue.length() != 0) {
                    map.put(paramName, paramValue);
                }
            }
        }
JSON.toJSONString(map)
Enumeration enu=request.getParameterNames();  
while(enu.hasMoreElements()){  
String paraName=(String)enu.nextElement();  
System.out.println(paraName+": "+request.getParameter(paraName));  
}
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

你可能感兴趣的:(Java,java)