JSP JSTL < x: when > Tags: execute code according to conditions

< x: when select = "XPATHexpression" > body content < / X: when >

Example

<%@taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml"%>
  <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
    <c:import url="bookInfo.xml" var="xmlFile" charEncoding="gbk"/>
    <x:parse var="bookInfo" doc="${xmlFile}"></x:parse>
    <x:choose>
      <x:when select="$bookInfo/books/book[name='JSP程序开发范例宝典'][sellAmount/
                      @value>5000]">非常畅销</x:when>
      <x:when select="$bookInfo/books/book[name='JSP程序开发范例宝典'][sellAmount/
                      @value<5000][sellAmount/@value>2000]">基本畅销</x:when>
      <x:when select="$bookInfo/books/book[name='JSP程序开发范例宝典'][sellAmount/
                      @value<2000]">不畅销</x:when>
    </x:choose>
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>