<X: set> tag
<X: set> pour définir la valeur d'une variable d'expressions XPath.
Si la valeur de l'expression XPath est de type booléen, puis <x: set> java.lang.Boolean sera fixé un objectif, si la chaîne, définissez un objet java.lang.String, et si les chiffres, définissez un java.lang objet .Nombre.
syntaxe
<x:set var="<string>" select="<string>" scope="<string>"/>
propriété
<X: set> tag possède les attributs suivants:
propriété | description | le cas échéant | Par défaut |
---|---|---|---|
var | Au nom digne expression XPath variables | il est | corps |
sélectionner | expression XPath à calculer | aucun | aucun |
portée | attribut var Scope | aucun | page |
Exemples Démo
L'exemple suivant montre comment utiliser le <x: set> tag:
<%@ 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 标签</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>
Les résultats sont les suivants:
BOOKS INFO: The price of the second book:[[book: null], [book: null]]