黄色电影一区二区,韩国少妇自慰A片免费看,精品人妻少妇一级毛片免费蜜桃AV按摩师 ,超碰 香蕉

<x:forEach> 標(biāo)簽

<x:forEach> 標(biāo)簽

JSP 標(biāo)準(zhǔn)標(biāo)簽庫(kù)JSP 標(biāo)準(zhǔn)標(biāo)簽庫(kù)

<x:forEach>標(biāo)簽用來(lái)循環(huán)遍歷XML文檔的節(jié)點(diǎn)。

語(yǔ)法格式

<x:forEach
   var="<string>"
   select="<string>"
   begin="<int>"
   end="<int>"
   step="<int>"
   varStatus="<string>">

屬性

<x:forEach>標(biāo)簽有如下屬性:

屬性 描述 是否必要 默認(rèn)值
select 需要計(jì)算的XPath表達(dá)式 無(wú)
var 用于存儲(chǔ)當(dāng)前項(xiàng)目的變量 無(wú)
begin 迭代器的開(kāi)始索引 無(wú)
end 迭代器的結(jié)束索引 無(wú)
step 迭代的步長(zhǎng) 無(wú)
varStatus 代表迭代器所存儲(chǔ)的狀態(tài)的變量 無(wú)

實(shí)例演示

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %>

<html>
<head>
  <title>JSTL x:forEach 標(biāo)簽</title>
</head>
<body>
<h3>Books Info:</h3>

<c:set var="xmltext">
  <books>
    <book>
      <name>Padam History</name>
      <author>ZARA</author>
      <price>100</price>
    </book>
    <book>
      <name>Great Mistry</name>
      <author>NUHA</author>
      <price>2000</price>
    </book>
  </books>
</c:set>

<x:parse xml="${xmltext}" var="output"/>
<ul class="list">
<x:forEach select="$output/books/book/name" var="item">
   <li>Book Name: <x:out select="$item" /></li>
</x:forEach>
</ul>

</body>
</html>

運(yùn)行結(jié)果如下:

BOOKS INFO:
Book Name: Padam History

Book Name: Great Mistry

JSP 標(biāo)準(zhǔn)標(biāo)簽庫(kù)JSP 標(biāo)準(zhǔn)標(biāo)簽庫(kù)

相關(guān)文章