getParameterMap()的返回值为Map,从其中取得请求参数转为Map的方法如下:

直接遍历报错:[Ljava.lang.String;@44739f3f

Map<String, String> tempMap = new HashMap<String, String>();
        Map<String, String[]> reqMap = req.getParameterMap();  
        Set<Entry<String, String[]>> set = reqMap.entrySet();  
        Iterator<Entry<String, String[]>> it = set.iterator();  
        while (it.hasNext()) {  
            Entry<String, String[]> entry = it.next();  
 
            System.out.println("KEY:"+entry.getKey());  
            for (String str : entry.getValue()) {  
                System.out.println(str);  
                tempMap.put(entry.getKey(), str);
            }  
        }

顺便写一下Map的遍历:

Set<Map.Entry<String, String>> itermap = resMap.entrySet();
        for (Map.Entry<String, String> entry : itermap) {
            String key = entry.getKey();
            String value = entry.getValue();
            System.out.println(key + ": " + value);

}

上一篇:Vs2012帮助文档安装介绍


下一篇:C# Interlocked 笔记