map里面的值为[{id=5,name=张三},{id=7,name=王五}]
这样的map我该如何取值?

解决方案 »

  1.   

    很简单
    jsp页面上这么写
    <%
       HashMap map;//前提有你的map,随便你存哪里,request.getSession().getAttribute();
       String id = (String) map.get("id");
       String name = (String) map.get("name");
    %>
      

  2.   

    用标签,怎么写?我这里是struts1
      

  3.   

    看错了,还以为你map是这样呢{id=5,name=张三}这样取的到吗?学习
      

  4.   

    HashMap map = new HashMap();

    HashMap m1 = new HashMap();
    m1.put("id","5");
    m1.put("name","张三");

    HashMap m2 = new HashMap();
    m2.put("id","54");
    m2.put("name","2342");

    map.put(m1,m2);

    for(int i =0; i < map.size(); i++){
    HashMap map2 = (HashMap) map.get(m1);
    System.out.println(map2);
    }这样才能取到{name=2342, id=54}
    根本就不可能取到吧?!等高手
      

  5.   

    就直接用 map.put(54,'张三') 这样不行么?
      

  6.   

    你是每个数据都要取到还是就取姓名? map可以转换成list集合的 用list遍历吧
      

  7.   

    可以在结果集传入到页面之前进行处理,把每个数组里面的Hash转换成Set。