TUTORIALBackendFETCHED

fn:endsWith()函数

fn:endsWith()函数 JSP 标准标签库 fn:endsWith()函数用于确定一个字符串是否以指定后缀结尾。 语法 fn:endsWith()函数的语法如下: ... 实例演示 以下实例演示了这个函数的功能: 使用 JSTL 函数 字符串以 123 结尾 字符串以 runoob 结尾 运行结果如下: 字符串以 123 结尾 JSP 标准标签库..

Updated 7/16/2026

Tutorial detail pages default to noindex.

fn:endsWith()函数

JSP 标准标签库JSP 标准标签库

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

语法

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

<c:if test="${fn:endsWith(<原始字符串>, <要查找的子字符串>)}">
...
</c:if>

实例演示

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

<%@ 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="theString" value="I am from runoob 123"/>

<c:if test="${fn:endsWith(theString, '123')}">
   <p>字符串以 123 结尾<p>
</c:if>

<c:if test="${fn:endsWith(theString, 'unoob')}">
   <p>字符串以 runoob 结尾<p>
</c:if>

</body>
</html>

运行结果如下:

字符串以 123 结尾

JSP 标准标签库JSP 标准标签库