解决方案 »

  1.   

    应该是map里面的值有问题,把map里的值打印出看看,或者断点下测试输出正常
      

  2.   

    貌似request.getParameterMap() 返回的是个Map<String,String[]>
    不是Map<String,String>吧
    所以强转报错了
      

  3.   


    不是你说的这样的 这个是eclipse中提示的apiSet<Entry<String, String>> java.util.Map.entrySet()Returns a Set view of the mappings contained in this map. The set is backed by the map, so changes 
     to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the 
     set is in progress (except through the iterator's own remove operation, or through the setValue 
     operation on a map entry returned by the iterator) the results of the iteration are undefined. The set 
     supports element removal, which removes the corresponding mapping from the map, via the 
     Iterator.remove, Set.remove, removeAll, retainAll and clear operations. It does not support the add or 
     addAll operations. 
    Returns:
    a set view of the mappings contained in this map
      

  4.   

      你说的这个跟我的  好像不是一码事。。   我这个是request中的。。
      

  5.   

    Map<String,String> map=request.getParameterMap();
    改为这个
    Map<String,String[]> map = request.getParameterMap();
    看request的Api
      

  6.   


    getParameterMap
    public Map getParameterMap()
    The default behavior of this method is to return getParameterMap() on the wrapped request object. Specified by:
    getParameterMap in interface ServletRequest
    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.
    The values in the parameter map are of type String array.
    Map<String, String[]> map = request.getParameterMap();
    Set<Map.Entry<String, String[]>> entry = map.entrySet();
      

  7.   

    import java.util.HashMap;
    import java.util.Map;
    import java.util.Set;public class Test17 { public static void main(String[] args) { Map<String, String[]> map = new HashMap<String,String[]>();
    map.put("B", new String[]{"B","C","D"});
    map.put("A", new String[]{"B","C","D"});
    Set<Map.Entry<String, String[]>> entry = map.entrySet();
    for (Map.Entry<String, String[]> entry_ : entry) {
    System.out.println(entry_.getKey().toString() + ":"
    + java.util.Arrays.toString(entry_.getValue()));
    } }}
      

  8.   


    谢谢你 ,@shixitong 。你这个可以  但是我想问   entry_.getValue()   得到的是内存地址   怎么得到真实值。。
      

  9.   

    谢谢你 ,@shixitong    
         已经知道了   entry_.getValue()[0]   这个得到的是数组。。
      

  10.   


    谢谢你 ,@shixitong 。你这个可以  但是我想问   entry_.getValue()   得到的是内存地址   怎么得到真实值。。
    为什么说是内存地址,依据是什么,java里是得不到内存地址的