我将数据库查询结果保存在Result类型的变量A中通过Servlet 
request.setAttribute("pet_List", A);
RequestDispatcher dispatcher=request.getRequestDispatcher("petview_name.jsp");
dispatcher.forward(request, response);
转发到显示页面,请问在显示页面怎么通过标签输出,显示页面不要有jsp代码。

解决方案 »

  1.   

    <c:forEach var="ins" items="${pet_List}">
    ${ins}</c:forEach>
      

  2.   

    在显示页面怎么将这个二维表通过标签ForEach遍历????
      

  3.   

    c标签中有个Iterator ,可以用来迭代集合。
      

  4.   

    pet_List是二维的,你的意思是list里面的每个元素还是list??
    要是这样的话forEach同样用呀。
    <c:forEach var="ins" items="${pet_List}">
      <c:set var="list" value="${ins}"/>
      <c:forEach var ="obj" items="${list}">
        ${obj.xxx}
      </c:forEach>
    </c:forEach>
      

  5.   

    我的显示页面是这样的
    <%
    //书名:bname
    //作者:author
    //价格:price
    Result ds=dao.ListBook();
    out.print(ds.getRowsByIndex()[0][2]);
    %>
    <table width="70%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <th>书名</th>
        <th>作者</th>
        <th>价格(元)</th>
        <th>操作</th>
      </tr>
    <c:forEach var="book" items="${ds}" varStatus="status">
      <tr>
        <td></td>
        <td> </td>
        <td> </td>
        <td> </td>
      </tr>
    </c:forEach>
    </table> 
      

  6.   

    就是从数据库读取记录放在Result类型的对象中在前台页面中用jstl标签把记录按我11楼的形式显示出来。