Latest web development tutorials

JSTL의 FN : 같이 IndexOf () 함수

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

FN : 같이 IndexOf () 함수는 지정된 문자열 위치에 문자열을 반환합니다.

문법

FN 다음과 같이 구문 같이 IndexOf () 함수는 다음과 같습니다

${fn:indexOf(<原始字符串>,<子字符串>)}

예를 들면 데모

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

<%@ 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>Using JSTL Functions</title>
</head>
<body>

<c:set var="string1" value="This is first String."/>
<c:set var="string2" value="This <abc>is second String.</abc>"/>

<p>Index (1) : ${fn:indexOf(string1, "first")}</p>
<p>Index (2) : ${fn:indexOf(string2, "second")}</p>

</body>
</html>

결과는 다음과 같습니다 :

Index (1) : 8
Index (2) : 13

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