JSTL中类似if else的标签使用例子

来源:互联网 发布:全民突击辅助软件 编辑:程序博客网 时间:2024/05/20 11:36

jstl:Java Standard Tag Libraray 下载地址:http://tomcat.apache.org/taglibs/standard/

<c:choose>就像Java switch语句,它可以让你选择一些替代方案品。正如switch语句case语句,

<c:choose>标签有<c:when>的标签。一个switch语句中有default子句来指定一个默认的行动同样的方式<c:choose>有<c:otherwise>作为默认子句

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %><html><head><title><c:choose> Tag Example - www.yiibai.com</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>

运行:

Your salary is : 4000Salary is very good. 


0 0
原创粉丝点击