JSP/JSTL functions

[JSP][JSTL functions] fn:length()

지니★ 2021. 7. 26. 14:42
728x90
728x90
SMALL

 


 

fn:length()

  • 컬렉션의 항목 수 또는 문자열의 문자 수를 반환합니다.

 

Syntax

int length(java.lang.Object)

 

Example

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<html>
    <head>
        <title>JSTL functions length</title>
    </head>
    <body>
        <c:set var="str1" value="Hello."/>
        <c:set var="str2" value="Hello World."/>
        
        <p>Length of String1 : ${fn:length(str1)}</p>
        <p>Length of String2 : ${fn:length(str2)}</p>
   </body>
</html>

 

Result

Length of String1 : 6
Length of String2 : 12

 


 

728x90
728x90
LIST

'JSP > JSTL functions' 카테고리의 다른 글

[JSP][JSTL functions] fn:split()  (0) 2021.07.30
[JSP][JSTL functions] fn:replace()  (0) 2021.07.26
[JSP][JSTL functions] fn:join()  (0) 2021.07.26
[JSP][JSTL functions] fn:indexOf()  (0) 2021.07.26
[JSP][JSTL functions] fn:escapeXml()  (0) 2021.07.26