English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
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 w3codebox 123"/> <c:if test="${fn:endsWith(theString, '123')}"> <p>文字列が 123 終わり<p> </c:if> <c:if test="${fn:endsWith(theString, 'hooo')}"> <p>文字列が w3codebox 終わり<p> </c:if> </body> </html>
実行結果は以下の通りです:
文字列が 123 終わり