English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

La función fn:endsWith() de JSTL

Biblioteca de etiquetas estándar de JSP

La función fn:endsWith() se utiliza para determinar si una cadena de caracteres termina con un sufijo específico.

语法

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" %>


使用 JSTL 函数
</head>


<c:if test="${fn:endsWith(theString, '123')}>
   <p>Cadena con 123 final<p>
</c:if>
<c:if test="${fn:endsWith(theString, 'hooo')}">
   <p>Cadena con espacio en w3codebox final<p>
</c:if>
</body>
</html>

Los resultados de ejecución son los siguientes:

La cadena comienza con 123 Final

Biblioteca de etiquetas estándar de JSP