Latest web development tutorials

<Fmt: setBundle> tag

JSP Standard Tag Library JSP Standard Tag Library

<Fmt: setBundle> tag is used to load a resource bundle, then store it in a variable named scope or bundle configuration variables.

Syntax

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

Attributes

<Fmt: setBundle> tag has the following attributes:

Attributes description If necessary Defaults
basename Family resource bundle base name, exposed to variable scope or Configuration Variables Yes no
var Variable to store the new resource bundle no Replace default
scope Variable scope no Page


Examples Demo

<%@ 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>

Results are as follows:

One 
Two 
Three

JSP Standard Tag Library JSP Standard Tag Library