JSTL標準函數總結,jstl函數總結

來源:互聯網
上載者:User

JSTL標準函數總結,jstl函數總結

jstl標準函數

在使用這些函數之前必須在JSP中引入標準函數的聲明

<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>

下面是JSTL中內建的方法列表以及其描述

  

函數名

函數說明

使用舉例

 contains

判斷字串是否包含另外一個字串

<c:if test="${fn:contains(name, searchString)}">

 containsIgnoreCase

判斷字串是否包含另外一個字串(大小寫無關)

<c:if test="${fn:containsIgnoreCase(name, searchString)}">

 endsWith

判斷字串是否以另外字串結束

<c:if test="${fn:endsWith(filename, ".txt")}">

 escapeXml

把一些字元轉成XML表示,例如<字元應該轉為<

${fn:escapeXml(param:info)}

 indexOf

子字串在母字串中出現的位置

${fn:indexOf(name, "-")}

 join

將數組中的資料聯合成一個新字串,並使用指定字元格開

${fn:join(array, ";")}

 length

擷取字串的長度,或者數組的大小

${fn:length(shoppingCart.products)}

 replace

替換字串中指定的字元

${fn:replace(text, "-", "•")}

 split

把字串按照指定字元切分

${fn:split(customerNames, ";")}

 startsWith

判斷字串是否以某個子串開始

<c:if test="${fn:startsWith(product.id, "100-")}">

 substring

擷取子串

${fn:substring(zip, 6, -1)}

 substringAfter

擷取從某個字元所在位置開始的子串

${fn:substringAfter(zip, "-")}

 substringBefore

擷取從開始到某個字元所在位置的子串

${fn:substringBefore(zip, "-")}

 toLowerCase

轉為小寫

${fn.toLowerCase(product.name)}

 toUpperCase

轉為大寫字元

${fn.UpperCase(product.name)}

 trim

去除字串前後的空格

${fn.trim(name)}

 

 

著作權聲明:歡迎轉載,希望在你轉載的同時,添加原文地址,謝謝配合

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.