[Ljava.lang.String; cannot be cast to java.lang.String错误 [转]

[Ljava.lang.String; cannot be cast to java.lang.String错误 


今天使用request.getParameterMap()获得Map中的数据时,使用
       Map map=hrequest.getParameterMap();
            Set key = map.keySet();
            for(Object aaa: key.toArray()){
             parakey = aaa.toString();
             paravalue = (String)map.get(aaa);
             requestpath = requestpath+"?"+parakey+"="+paravalue;
            }

报[Ljava.lang.String; cannot be cast to java.lang.String错误,上网查了才知道get(key)返回的是String[],所以要使用字符串数组转换读取……恩。我是这样解决的:
Map map=hrequest.getParameterMap();
            Set key = map.keySet();
            for(Object aaa: key.toArray()){
             parakey = aaa.toString();
             paravalue = ((String[])map.get(aaa))[0];
             requestpath = requestpath+"?"+parakey+"="+paravalue;
            }

你可能感兴趣的:(String)