<FMT:setBundle>タグ
<FMT:setBundle>タグは、スコープまたはバンドル構成変数という名前の変数に格納、その後、リソースバンドルをロードするために使用されます。
構文
<fmt:setBundle baseName="<string>" var="<string>" scope="<string>"/>
プロパティ
<FMT:setBundle>タグには、次の属性があります。
プロパティ | 説明 | 必要に応じて | デフォルト |
---|---|---|---|
ベース名 | ファミリーリソースバンドルのベース名、変数のスコープまたは構成変数にさらさ | それは | いいえ |
VAR | 新しいリソースバンドルを格納する変数 | いいえ | デフォルトを交換します |
スコープ | 変数のスコープ | いいえ | ページ |
例のデモ
<%@ 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.w3big.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