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表示,例如<字符應該轉爲&lt; ${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)} JSTL中自帶的方法列表 面是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)}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章