欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

JSP中使用JSTL按不同條件輸出內(nèi)容的方法

 更新時(shí)間:2015年10月10日 11:33:16   作者:紅薯  
這篇文章主要介紹了JSP中使用JSTL按不同條件輸出內(nèi)容的方法,實(shí)例分析了JSP標(biāo)簽庫JSTL的相關(guān)使用技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下

本文實(shí)例講述了JSP中使用JSTL按不同條件輸出內(nèi)容的方法。分享給大家供大家參考。具體如下:

ConditionalContentJSTL.jsp頁面:

<%@ page language="java" contentType="text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/tld/c-rt.tld" prefix="c-rt" %>
<html>
<head>
 <title>Java Code Geeks Snippets - Conditional Content with JSTL in JSP Page</title>
</head>
<body>
 <%-- if condition --%>
 <c-rt:if test='${param.myparam1 == "myvalue1"}'>
  This is printed if parameter "myparam1" equals "myvalue1" </br>
 </c-rt:if>
 <%-- if/else condition --%>
 <c-rt:choose>
  <c-rt:when test='${param.myparam2 == "myvalue2"}'>
   This is printed if parameter "myparam2" equals "myvalue2" </br>
  </c-rt:when>
  <c-rt:otherwise>
   This is printed if parameter "myparam2" DOES NOT equal "myvalue2" </br>
  </c-rt:otherwise>
 </c-rt:choose>
 <%-- multiple conditions --%>
 <c-rt:choose>
  <c-rt:when test='${param.myparam3 == "0"}'>
   This is printed if parameter "myparam1" equals 0 </br>
  </c-rt:when>
  <c-rt:when test='${param.myparam3 == "1"}'>
   This is printed if parameter "myparam1" equals 1 </br>
  </c-rt:when>
  <c-rt:otherwise>
   This is printed for any other value of the parameter </br>
  </c-rt:otherwise>
 </c-rt:choose>
</body>

希望本文所述對大家的JSP程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評論