java遍历http请求request的所有参数实现方法
通过程序遍历http请求的所有参数放到hashmap中,用的时候方便了。
如果参数值有中文,那么需要在程序中添加filter转码,或者在下面程序里,对paramValue转码
如下所示:
publicvoiddoGet(HttpServletRequestrequest,HttpServletResponseresponse)
throwsServletException,IOException{
Mapmap=newHashMap();
EnumerationparamNames=request.getParameterNames();
while(paramNames.hasMoreElements()){
StringparamName=(String)paramNames.nextElement();
String[]paramValues=request.getParameterValues(paramName);
if(paramValues.length==1){
StringparamValue=paramValues[0];
if(paramValue.length()!=0){
System.out.println("参数:"+paramName+"="+paramValue);
map.put(paramName,paramValue);
}
}
}
}
以上就是小编为大家带来的java遍历http请求request的所有参数实现方法的全部内容了,希望对大家有所帮助,多多支持毛票票~
热门推荐
10 新人红包祝福语简短精辟
11 幼师给毕业祝福语简短
12 生日高考祝福语妹妹简短
13 下飞机祝福语简短英文
14 元宵发客户祝福语简短
15 爸妈金婚文案祝福语简短
16 新郎朋友红包祝福语简短
17 虎年五一祝福语大全简短
18 出阁宴祝福语姐姐简短