<fmt:message> タグ

JSP 标准标签库JSP 標準タグライブラリ

<fmt:message>タグはキーワードをローカライズされたメッセージにマッピングし、パラメータ置換を実行します。

構文形式

<fmt:message
   key="<string>"
   bundle="<string>"
   var="<string>"
   scope="<string>"/>

属性

<fmt:message>タグには次の属性があります:

属性 説明 必須かどうか デフォルト値
key 取得するメッセージキー 否 Body
bundle 使用するリソースバンドル 否 デフォルトのリソースバンドル
var ローカライズされたメッセージを格納する変数名 否 Print to page
scope var属性のスコープ 否 Page


サンプルデモ

<%@ 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/fmt" prefix="fmt" %>
<html>
<head>
<title>JSTL fmt:message 标签</title>
</head>
<body>

<fmt:setLocale value="en"/>
<fmt:setBundle basename="com.サンプル.Example" var="lang"/>

<fmt:message key="count.one" bundle="${lang}"/><br/>
<fmt:message key="count.two" bundle="${lang}"/><br/>
<fmt:message key="count.three" bundle="${lang}"/><br/>

</body>
</html>

実行結果は次のとおりです:

One 
Two 
Three

JSP 标准标签库JSP 標準タグライブラリ

その他の拡張機能