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>
发表评论