Because it returns a String[]
, not a String
. The javadoc of getParameterMap()
also tells that:
Returns:
an immutable java.util.Map containing parameter names as keys and parameter values as map values. The keys in the parameter map are of type String. The values in the parameter map are of type String array.
So you need to treat it as an array. If you'd like to obtain a single (the first) parameter value, use request.getParameter()
instead. Here's a rewrite:
for (String name : Collections.<String>list(request.getParameterNames())) {
String value = request.getParameter(name);
logger.log(name + ": " + value);
}
Or if you really want to check all possible parameter values, then just iterate over the map's entryset:
Map<String, String[]> map = request.getParameterMap();
for (Entry<String, String[]> entry : map.entrySet()) {
String name = entry.getKey();
String[] values = entry.getValue();
logger.log(name + ": " + Arrays.toString(values));
}