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)文章
JSP servlet實(shí)現(xiàn)文件上傳下載和刪除
這篇文章主要為大家詳細(xì)介紹了JSP servlet實(shí)現(xiàn)文件上傳下載和刪除,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-12-12JSP連接MySql/MS SQL Server/Oracle數(shù)據(jù)庫連接方法[整理]
這個(gè)經(jīng)常整理更新2008-10-10JAVA/JSP學(xué)習(xí)系列之二(Tomcat安裝)
JAVA/JSP學(xué)習(xí)系列之二(Tomcat安裝)...2006-10-10