<X : 경우> 태그
<X : 경우> 태그가 참일 경우, XPath 식의 값을 결정하는데 사용되는 콘텐츠 인 경우, 그 몸체의 내용이 거짓 본체는 무시된다.
구문
<x:if select="<string>" var="<string>" scope="<string>"> ... </x:if>
재산
<X : 경우> 태그는 다음과 같은 특성이 있습니다 :
재산 | 기술 | 필요한 경우 | 디폴트 값 |
---|---|---|---|
선택 | XPath 식을 계산한다 | 그것은 인 | 아니 |
VAR | 가변 저장 조건의 결과 | 아니 | 아니 |
범위 | 범위 var 애트리뷰트 | 아니 | 페이지 |
예를 들면 데모
태그 : 다음 예는 <경우 X>를 사용하는 방법을 보여줍니다 :
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ 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:if 标签</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:if select="$output//book"> Document has at least one <book> element. </x:if> <br /> <x:if select="$output/books[1]/book/price > 100"> Book prices are very high </x:if> </body> </html>
결과는 다음과 같습니다 :
BOOKS INFO: Document has at least one <book> element. Book prices are very high