The fn:indexOf() function
The fn:indexOf() function returns the position of a specified substring within a string.
Syntax
The syntax of the fn:indexOf() function is as follows:
${fn:indexOf(<原始字符串>,<子字符串>)}
Example Demonstration
The following example demonstrates the function:
<%@ 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" %>
Using JSTL Functions
Index (1) : ${fn:indexOf(string1, "first")}
Index (2) : ${fn:indexOf(string2, "second")}
The running result is as follows:
Index (1) : 8
Index (2) : 13
JSP Standard Tag Library