JSTL fn:endsWith()函数

fn:endsWith()函数用于确定一个字符串是否以指定后缀结尾。

 

语法

fn:endsWith()函数的语法如下:

boolean endsWith(java.lang.String, java.lang.String)

 

实例演示

以下实例演示了这个函数的功能:

<%@ 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 a test String 123"/>

<c:if test="${fn:endsWith(theString, '123')}">
   <p>String ends with 123<p>
</c:if>

<c:if test="${fn:endsWith(theString, 'TEST')}">
   <p>String ends with TEST<p>
</c:if>

</body>
</html>

运行结果如下:

String ends with 123