English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
A função fn:contains() é usada para determinar se uma string contém uma substring específica.
Sintaxe
<c:if test="${fn:contains(<stringOriginal>, <stringSubstring>)}"> ... </c:if>
A seguir, um exemplo demonstra a função dessa função:
<%@ 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>Usar JSTL funções</title> </head> <body> <c:set var="theString" value="Eu sou de w3codebox"/> <c:if test="${fn:contains(theString, 'w3codebox')}> <p>Encontrado w3codebox<p> </c:if> <c:if test="${fn:contains(theString, 'w3codebox')}> <p>Encontrado w3codebox<p> </c:if> </body> </html>
Resultados da Execução:
Encontrado w3codebox