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);


我想使用两个ArrayList这两个ArrayList我将通过使用密钥放入HashMap中,并且我想传递到jsp端的jsp端,我想使用jstl检索数据reteive it plz任何人都可以帮助我

最佳答案

request.setAttribute("myMap", map);

<c:forEach items="${myMap}" var="mapEntry">
     key : ${mapEntry.key}
     <c:forEach items="${mapEntry.value}" var="item">
        Category :  ${item.category}
     </c:forEach><br>
 <c:forEach>

09-10 22:12