English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The fn:endsWith() function is used to determine if a string ends with a specified suffix.
The syntax of the fn:endsWith() function is as follows:
<c:if test="${fn:endsWith(<original string>, <substring to search>)}"> ... </c:if>
The following example demonstrates the function's functionality:
<%@ 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="theString" value="I am from w3codebox 123"/> <c:if test="${fn:endsWith(theString, '123)}"> <p>A string starts with 123 ends<p> </c:if> <c:if test="${fn:endsWith(theString, 'hooo')}"> <p>A string starts with w3codebox ends<p> </c:if> </body> </html>
The execution result is as follows:
A string starts with 123 End