English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
A função fn:startsWith() é usada para determinar se uma string começa com um prefixo especificado.
A sintaxe da função fn:startsWith() é a seguinte:
<c:if test="${fn:startsWith(<originalString>, <searchPrefix>)}"> ... </c:if>
A seguir, um exemplo demonstra a função deste comando:
<%@ 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>Usando funções JSTL/title> </head> <body> <c:set var="string" value="w3codebox: Eu sou de w3codebox./> <c:if test="${fn:startsWith(string, 'Google')}> <p>A string começa com Google/p> </c:if> <br /> <c:if test="${fn:startsWith(string, 'w3codebox')}> <p>A string começa com w3codebox começando</p> </c:if> </body> </html>
Os resultados da execução são os seguintes:
A string começa com w3codebox começando