<fmt:setBundle> タグ

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

<fmt:setBundle>タグはリソースバンドルをロードし、それをスコープ内の名前付き変数またはbundle設定変数に格納するために使用されます。

構文形式

<fmt:setBundle baseName="<string>" var="<string>" scope="<string>"/>

属性

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

属性 説明 必須かどうか デフォルト値
basename リソースバンドルファミリーのベース名。スコープ変数または設定変数に公開されます。 である 无
var 新しいリソースバンドルを格納する変数 否 Replace default
scope 変数のスコープ 否 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:setBundle 标签</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 標準タグライブラリ

その他の拡張