?
本文檔使用 PHP中文網(wǎng)手冊 發(fā)布
<c:choose>標簽與Java switch語句的功能一樣,用于在眾多選項中做出選擇。switch語句中有case,而<c:choose>標簽中對應(yīng)有<c:when>,switch語句中有default,而<c:choose>標簽中有<c:otherwise>。
屬性 | 描述 | 是否必要 | 默認值 |
---|---|---|---|
test | 條件 | 是 | 無 |
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <html> <head> <title>c:choose 標簽實例</title> </head> <body> <c:set var="salary" scope="session" value="${2000*2}"/> <p>Your salary is : <c:out value="${salary}"/></p> <c:choose> <c:when test="${salary <= 0}"> Salary is very low to survive. </c:when> <c:when test="${salary > 1000}"> Salary is very good. </c:when> <c:otherwise> No comment sir... </c:otherwise> </c:choose> </body> </html>
運行結(jié)果如下:
Your salary is : 4000 Salary is very good.
關(guān)于我們 聯(lián)系我們 留言板
手冊網(wǎng)