Latest web development tutorials

<X: set> tag

Biblioteca JSP Standard Tag Biblioteca JSP Standard Tag

<X: set> per impostare il valore di una variabile espressioni XPath.

Se il valore dell'espressione XPath è di tipo booleano, quindi <x: insieme> java.lang.Boolean sarà fissato un obiettivo, se la stringa, impostare un oggetto java.lang.String, e se le cifre, impostare un java.lang oggetto .Numero.

sintassi

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

proprietà

<X: set> tag ha i seguenti attributi:

proprietà descrizione Se necessario difetto
var A nome del degna espressione XPath variabile è corpo
selezionare espressione XPath da calcolare no no
portata attributo var Scope no pagina


Esempi Demo

L'esempio seguente mostra come utilizzare il <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>

I risultati sono i seguenti:

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

Biblioteca JSP Standard Tag Biblioteca JSP Standard Tag