Latest web development tutorials

JSTL의 FN : 트림 () 함수

JSP 표준 태그 라이브러리 JSP 표준 태그 라이브러리

FN : 공백 문자열을 제거 기능이 종료 () 트림.

문법

FN : 트림 () 함수의 구문은 다음과 같습니다

${fn.trim(<string>)}

예를 들면 데모

다음의 예는이 함수의 성능을 보여 :

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<html>
<head>
<title>使用 JSTL 函数</title>
</head>
<body>

<c:set var="string1" value="I am from w3big         "/>
<p>string1 长度 : ${fn:length(string1)}</p>

<c:set var="string2" value="${fn:trim(string1)}" />
<p>string2 长度 : ${fn:length(string2)}</p>
<p>字符串为 : ${string2}</p>

</body>
</html>

결과는 다음과 같습니다 :

string1 长度 : 25

string2 长度 : 16

字符串为 : I am from w3big

JSP 표준 태그 라이브러리 JSP 표준 태그 라이브러리