java集合用作地图和检索数据

ran*_*kit 1 java jsp jstl arraylist map

Map<String, List<OfferBean>> map = new HashMap<String, List<OfferBean>>();
            List<OfferBean> al=new ArrayList<OfferBean>();
            OfferBean of=null;
            sql="select * from catgory";
            ps1=c.prepareStatement(sql);
            ps1.execute();
            rs=ps1.getResultSet();
            if(rs.next())
            {
                System.out.println("inside loop of if");
                sql="select * from catgory";
                ps1=c.prepareStatement(sql);
                ps1.execute();
                rs=ps1.getResultSet();
                while(rs.next())
                {
                    of=new OfferBean();
                    System.out.println("inside loop of while");
                    of.setCategory(rs.getString("catgoryname"));
                    al.add(of);
                }
           map.put("key", al);
Run Code Online (Sandbox Code Playgroud)

我想用两个ArrayList两个ArrayList我会把里面HashMap用钥匙,我想传递给jsp在一旁jsp一边我想用检索的数据jstl是如何reteive PLZ任何一个可以帮助我

new*_*ser 5

 request.setAttribute("sampleMap", map);   
Run Code Online (Sandbox Code Playgroud)

尝试c:forEach

 <c:forEach var="sample" items="${sampleMap}">
     Key : ${sample.key}
   <c:forEach var="list" items="${sample.value}">
          Category - ${list.category} //you can access all the values of `OfferBean`
    </c:forEach>
  </c:forEach>
Run Code Online (Sandbox Code Playgroud)

查看访问列表元素