fn:endsWith()関数
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 サンプル 123"/>
<c:if test="${fn:endsWith(theString, '123')}">
<p>字符串以 123 结尾<p>
</c:if>
<c:if test="${fn:endsWith(theString, 'unoob')}">
<p>字符串以 サンプル 结尾<p>
</c:if>
</body>
</html>
実行結果は次のとおりです:
字符串以 123 结尾
その他の拡張
JSP 標準タグライブラリ