JSTL函數標籤庫 fn標籤,jstl函數fn標籤

來源:互聯網
上載者:User

JSTL函數標籤庫 fn標籤,jstl函數fn標籤

在使用jstl的函數標籤庫之前需要在頁面中引入:

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

 

1、fn:contains(string, substring)
如果參數string中包含參數substring,返回true。

 

2、fn:containsIgnoreCase(string, substring)
如果參數string中包含參數substring(忽略大小寫),返回true

 

3、fn:endsWith(string, suffix)
如果參數 string 以參數suffix結尾,返回true。

 

4、fn:escapeXml(string)
將有特殊意義的XML (和HTML)轉換為對應的XML character entity code,並返回。

5、fn:indexOf(string, substring)
返回參數substring在參數string中第一次出現的位置。

 

6、fn:join(array, separator)
將一個給定的數組array用給定的間隔符separator串在一起,組成一個新的字串並返回。 

 

7、fn:length(item)
返回參數item中包含元素的數量。參數Item類型是數組、collection或者String。如果是String類型,傳回值是String中的字元數。

 1     <body>        2         <% 3             String a[] = {"aa","bb","cc","dd"}; 4             request.setAttribute("array",a); 5             request.setAttribute("store","guomei8899"); 6         %>  7         <c:if test="${fn:contains('guomeiddd','guoMei')}">ok</c:if><br> 8         <c:if test="${fn:containsIgnoreCase(store,'guoMei')}">ok ok</c:if><br> 9         <c:if test="${fn:endsWith(store,'99')}">end</c:if><br>10         <c:out value="${fn:escapeXml('<>')}"/><br>11         <c:out value="${fn:indexOf(store,'om')}"/><br>12         <c:out value="${fn:join(array,'|')}"/><br>13         <c:out value="${fn:length(array)}"/><br>14     </body> 

8、fn:replace(string, before, after)
返回一個String對象。用參數after字串替換參數string中所有出現參數before字串的地方,並返回替換後的結果。

 

9、fn:startsWith(string, prefix)
如果參數string以參數prefix開頭,返回true。

 

10、fn:substring(string, begin, end)
返回參數string部分字串, 從參數begin開始到參數end位置。

 

11、fn:substringAfter(string, substring)
返回參數substring在參數string中後面的那一部分字串。

 

12、fn:substringBefore(string, substring)
返回參數substring在參數string中前面的那一部分字串。

 

13、fn:toLowerCase(string)
將參數string所有的字元變為小寫,並將其返回。

 

14、fn:toUpperCase(string)
將參數string所有的字元變為大寫,並將其返回。

 

15、fn:trim(string)
去除參數string 首尾的空格,並將其返回。

 1     <body>        2         <% 3             String a[] = {"aa","bb","cc","dd"}; 4             request.setAttribute("array",a); 5             request.setAttribute("store","guomei8899"); 6             request.setAttribute("user","u1,u2,u3,u4,u5"); 7             request.setAttribute("test","aBcDeF   "); 8         %>  9         <c:out value="${fn:replace(store,'8','9')}"/><br>10         <c:out value="${fn:split(user,',')}"/><br>11         <c:out value="${fn:startsWith(store,'g')}"/><br>12         <c:out value="${fn:substring(store,2,5)}"/><br>13         <c:out value="${fn:substringAfter(store,'mei')}"/><br>14         <c:out value="${fn:substringBefore(store,'mei')}"/><br>15         <c:out value="${fn:toLowerCase(test)}"/><br>16         <c:out value="${fn:toUpperCase(test)}"/><br>17         <c:out value="${test}hoho"/><br>18         <c:out value="${fn:trim(test)}hoho"/><br>19     </body>

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.