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

我想使用两个ArrayListArrayList我将通过使用密钥放入HashMap其中,我想传递到jsp一侧jsp我想使用jstl如何检索数据来检索数据请任何人帮助我

4

2 回答 2

5
 request.setAttribute("sampleMap", map);   

尝试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>

看看访问列表的元素

于 2013-09-02T05:34:35.397 回答
2
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>
于 2013-09-02T05:39:05.277 回答