English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The <fmt:setBundle> tag is used to load a resource bundle and then store it in a named variable in the scope or in the bundle configuration variable.
<fmt:setBundle baseName="<string>" var="<string>" scope="<string>"/>
The <fmt:setBundle> tag has the following attributes:
Attribute | Description | Is necessary | Default value |
---|---|---|---|
basename | Resource bundle family base name, exposed to scope variables or configuration variables | Is | None |
var | Variable for storing new resource bundle | No | Replace default |
Scope | Variable Scope | No | 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 Tag</title> </head> <body> <fmt:setLocale value="en"/> <fmt:setBundle basename="com.w3codebox.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>
The running result is as follows:
One Two Three