choose标签简介
choose标签包含两个子标签:when标签(必须标签)和otherwise标签(非必须标签),choose标签的作用类似Java中的switch语句,用于做出多项选择,而其子标签when标签则相当于case,otherwise则相当于default。
choose标签的语法
…
…
…
…
…
实例代码如下:
<%@ page contentType="text/html;charset=UTF-8" language="java" %><%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%><html><head><title>JSTL标签的使用</title></head><body><%request.setAttribute("score",88);%><c:if test="${score==80}"><h2>没问题呀!</h2></c:if><c:choose><c:when test="${score<60}"><h2>你这个小渣渣!</h2></c:when><c:when test="${score>=60&&score<80}"><h2>哎呀,不错哟!</h2></c:when><c:when test="${score>=80}"><h2>你好棒棒哦!</h2></c:when><c:otherwise><h2>你的分数可真是太奇葩了!</h2></c:otherwise></c:choose></body></html>
运行结果:
