<x:set> 標(biāo)簽
<x:set> 標(biāo)簽
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]]
相關(guān)文章
- JSP 簡(jiǎn)介
- JSP 開(kāi)發(fā)環(huán)境搭建
- Eclipse JSP/Servlet 環(huán)境搭建
- JSP 結(jié)構(gòu)
- JSP 指令
- JSP 隱式對(duì)象
- JSP 客戶端請(qǐng)求
- JSP 服務(wù)器響應(yīng)
- JSP 表單處理
- JSP 文件上傳
- JSP 日期處理
- JSP 頁(yè)面重定向
- JSP 點(diǎn)擊量統(tǒng)計(jì)
- JSP 自動(dòng)刷新
- JSP 標(biāo)準(zhǔn)標(biāo)簽庫(kù)(JSTL)
- JSP 連接數(shù)據(jù)庫(kù)
- JSP 表達(dá)式語(yǔ)言
- JSP 異常處理
- JSP 調(diào)試
- JSP 國(guó)際化