日期:2014-05-18  浏览次数:20874 次

request的getParameterMap()一个问题,在线等
页面传入几个参数,servlet的doPost()处理
Map   mapSearch=   request.getParameterMap();
Iterator   itSearch   =   mapSearch.entrySet().iterator();
while   (itSearch.hasNext())   {
Map.Entry   me=(Map.Entry)itSearch.next();
String   mapKey   =(String)   me.getKey();
String   mapValue   =   (String)   me.getValue();
}

String   mapValue   =     me.getValue().toString();执行到这一步报错
换种方法通过keySet()取Key的Set迭代,从mapSearch中用Key取Value,同样的到取Value出错
通过调试,mapSearch中为   参数   =[Ljava.lang.String;@6e3fe4     这种形式;
String   mapValue   =     me.getValue().toString();这样得到的mapValue   也为[Ljava.lang.String;@6e3fe4     这种形式
请问错在哪,该怎么改才能得到Value

------解决方案--------------------
me.getValue();可能是返回String[],默认长度 为1而已。估计是这样
------解决方案--------------------
me.getValue();会不会为空?还是判断一下的好!
------解决方案--------------------
String mapValue = me.getValue().toString();执行到这一步报错
=============================================
报什么错?
------解决方案--------------------
System.out.println(mapSearch);

看看上边能打出什么来.
------解决方案--------------------
关注下