JSP JSTL <x:choose>标签:完成条件判断

  • 内容
  • 评论
  • 相关

<x:choose> 标签与其子标签 <x:when> 和 <x:otherwise> 用于完成条件判断。

语法:

<x:choose>
  body content(<x:when>and<x:otherwise>subtags)
</x:choose>

示例

应用 <x:choose> 标签显示网店中“C”所处的成长阶段,关键代码如下:

<%@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="shopInfo.xml" var="xmlFile" charEncoding="gbk"/>
    <x:parse var="shopInfo" doc="${xmlFile}"></x:parse>
    <x:choose>
      <x:when select="$shopInfo/shops/shop[name='C'][sellAmount/@value>
                      500000]">商业能手</x:when>
      <x:when select="$shopInfo/shops/shop[name='C'][sellAmount/@value
                      <500000][sellAmount/@value>100000]">身手小试</x:when>
      <x:otherwise>初学下海</x:otherwise>
    </x:choose>

本文标题:JSP JSTL <x:choose>标签:完成条件判断

本文地址:http://www.hosteonscn.com/6380.html

评论

0条评论

发表评论

邮箱地址不会被公开。 必填项已用*标注