在Servlet的erequest中获得所有参数
- 摘要:获取request里的所有参数及参数名(参数名自动获取)-[Java]request里有两个方法request.getParameterMap();request.getParameterNames();我想用这两种方法获取。1。用request.getParameterNames();Enumerationenu=request.getParameterNames();while(enu.hasMoreElements()){StringparaName=(String)enu
- 标签:
monospace;" class="dp-j">
- 获取request里的所有参数及参数名(参数名自动获取)??-??[?Java?]??
- ??
- request里有两个方法??
- request.getParameterMap();??
- request.getParameterNames();??
- 我想用这两种方法获取。??
- 1。用request.getParameterNames();??
- Enumeration?enu=request.getParameterNames();??
- while(enu.hasMoreElements()){??
- String?paraName=(String)enu.nextElement();??
- System.out.println(paraName+":?"+request.getParameter(paraName));??
- }??
- ??
- 2。request.getParameterMap();??
- 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]);??
- ????????}??
- ??????}