請給出JSTL里面的c:forEach標(biāo)簽例子

c:forEach標(biāo)簽
馬克- to-win:馬克 java社區(qū):防盜版實名手機尾號: 73203。
完成諸如顯示ArrayList內(nèi)容的功能:

例 2.2.7

<%@ page contentType="text/html; charset=GBK"%>
<%@ page import="java.util.*"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<body>
<%
   ArrayList books=new ArrayList();
   books.add(new String("java入門"));
   books.add(new String("JSTL入門"));
   books.add(new String("C++精通"));
   books.add(new String("C++精通2"));
   books.add(new String("C++精通3"));
   books.add(new String("C++精通4"));
 /*note that you must use the following stetement to make the code inside scriptlet available
to the jsp page. */
   pageContext.setAttribute("booksq",books);
%>
   <c:forEach var="book" items="${booksq}" begin="1" end="3" step="1">
      <c:out value="${book}"/><br>
   </c:forEach>
</body>
</html>




運行jsp后,瀏覽器中輸出結(jié)果是:

JSTL入門
C++精通
C++精通2