Latest web development tutorials

<X : 세트> 태그

JSP 표준 태그 라이브러리 JSP 표준 태그 라이브러리

<X : 세트> 태그는 변수 XPath 식의 값을 설정합니다.

XPath 식의 값이 부울 유형, 다음의 경우 <X : 세트> java.lang.Boolean에이 목표를 설정하며, 문자열 경우 java.lang.String의 객체를 설정하고, 수치 경우 java.lang의 설정 .Number 객체입니다.

구문

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

재산

<X : 세트> 태그는 다음과 같은 특성이 있습니다 :

재산 기술 필요한 경우 디폴트 값
VAR 가치 변수 XPath 식 대신 그것은 인
선택 XPath 식을 계산한다 아니 아니
범위 범위 var 애트리뷰트 아니 페이지


예를 들면 데모

<: 집합 X> 태그 다음 예제를 사용하는 방법을 보여줍니다

<%@ 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>

결과는 다음과 같습니다 :

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

JSP 표준 태그 라이브러리 JSP 표준 태그 라이브러리