获取request里的所有参数及参数名(参数名自动获取) - [ Java ]
request里有两个方法:
1)request.getParameterMap();
Enumeration enu=request.getParameterNames();
while(enu.hasMoreElements()){
String paraName=(String)enu.nextElement();
System.out.println(paraName+": "+request.getParameter(paraName));
}
2)request.getParameterNames();
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]);
}
}