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

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

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

<x:set>標(biāo)簽為XPath表達(dá)式的值設(shè)置一個(gè)變量。

如果XPath表達(dá)式的值是boolean類型,則<x:set>將會(huì)設(shè)置一個(gè)java.lang.Boolean對(duì)象,若是字符串,則設(shè)置一個(gè)java.lang.String對(duì)象,若是數(shù)字,則設(shè)置一個(gè)java.lang.Number對(duì)象。

語(yǔ)法格式

<x:set var="<string>" select="<string>" scope="<string>"/>

屬性

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

屬性 描述 是否必要 默認(rèn)值
var 代表XPath表達(dá)式值得變量 Body
select 需要計(jì)算的XPath表達(dá)式 無(wú)
scope var屬性的作用域 Page

實(shí)例演示

接下來(lái)的例子告訴我們?nèi)绾问褂?lt;x:set>標(biāo)簽:

<%@ 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:set 標(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"/>
<x:set var="fragment" select="$output//book"/>
<b>The price of the second book</b>: 
<c:out value="${fragment}" />
</body>
</html>

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

BOOKS INFO:
The price of the second book:[[book: null], [book: null]]

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

相關(guān)文章
亚洲国产精品第一区二区,久久免费视频77,99V久久综合狠狠综合久久,国产免费久久九九免费视频