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

JSTL fn:startsWith()関数

JSP スタンダードタグライブラリ

fn:startsWith()関数は、指定された接頭辞で始まるかどうかを確認するために使用されます。

構文

fn:startsWith()関数の構文は以下の通りです:

<c:if test="${fn:startsWith(<原始字符串>, <搜索的前缀>)}">
            ...
</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="string" value="w3codebox: I am from w3codebox./>
<c:if test="${fn:startsWith(string, 'Google')}">
   <p>文字列が Google で始まる</p>
</c:if>
<br />
<c:if test="${fn:startsWith(string, 'w3codebox')}>
   <p>文字列が w3codebox 开頭</p>
</c:if>
</body>
</html>

実行結果は以下の通り:

文字列が w3codebox 开頭

JSP スタンダードタグライブラリ