获取request里的所有参数及参数名(参数名自动获取) - [ Java ]
request里有两个方法:
1)request.getParameterMap();
1 Enumeration enu=request.getParameterNames(); 2 while(enu.hasMoreElements()){ 3 String paraName=(String)enu.nextElement(); 4 System.out.println(paraName+": "+request.getParameter(paraName)); 5 }
2)request.getParameterNames();
1 Map map=request.getParameterMap(); 2 Set keSet=map.entrySet(); 3 for(Iterator itr=keSet.iterator();itr.hasNext();){ 4 Map.Entry me=(Map.Entry)itr.next(); 5 Object ok=me.getKey(); 6 Object ov=me.getValue(); 7 String[] value=new String[1]; 8 if(ov instanceof String[]){ 9 value=(String[])ov; 10 }else{ 11 value[0]=ov.toString(); 12 } 13 14 for(int k=0;k