1. 程式人生 > >jsp 擷取字串(EL表示式擷取字串)

jsp 擷取字串(EL表示式擷取字串)

${fn:split(tm2,".")[0]}

EL表示式擷取字串

1.首先在jsp頁面中匯入標籤庫:<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%> 2.格式化:${fn:split(results.biddingAmount,".")[0]}

下面是我在網上找到el表示式其他的一些用法

函式名 函式說明 使用舉例    fn:contains 判定字串是否包含另外一個字串 <c:if test="${fn:contains(name, searchString)}">   fn:containsIgnoreCase 判定字串是否包含另外一個字串(大小寫無關) <c:iftest="${fn:containsIgnoreCase(name, searchString)}">   fn:endsWith 判定字串是否以另外字串結束 <c:if test="${fn:endsWith(filename, ".txt")}">   fn:escapeXml 把一些字元轉成XML表示,例如 <字元應該轉為< ${fn:escapeXml(param:info)}    fn:indexOf 子字串在母字串中出現的位置 ${fn:indexOf(name, "-")}    fn:join 將陣列中的資料聯合成一個新字串,並使用指定字元格開 ${fn:join(array, ";")}    fn:length 獲取字串的長度,或者陣列的大小 ${fn:length(shoppingCart.products)}    fn:replace 替換字串中指定的字元 ${fn:replace(text, "-", "•")}    fn:split 把字串按照指定字元切分 ${fn:split(customerNames, ";")}    fn:startsWith 判定字串是否以某個子串開始 <c:if test="${fn:startsWith(product.id, "100-")}">   fn:substring 獲取子串 ${fn:substring(zip, 6, -1)}    fn:substringAfter 獲取從某個字元所在位置開始的子串    ${fn:substringAfter(zip, "-")}    fn:substringBefore 獲取從開始到某個字元所在位置的子串 ${fn:substringBefore(zip, "-")}    fn:toLowerCase 轉為小寫 ${fn.toLowerCase(product.name)}    fn:toUpperCase 轉為大寫字元 ${fn.UpperCase(product.name)}    fn:trim 去除字串前後的空格 ${fn.trim(name)}