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

直接遍历报错:[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);

        }

原文地址:https://www.cnblogs.com/herosoft/p/5694166.html