English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

<fmt:message> Tag

JSP Standard Tag Library

The <fmt:message> tag maps a keyword to a local message and then performs parameter substitution.

Syntax format

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

Attribute

The <fmt:message> tag has the following attributes:

AttributeDescriptionIs it necessaryDefault value
key Message keyword to be retrieved No Body
bundle Resource bundle to be used No Default resource bundle
var Variable name for storing local messages No Print to page
Scope The scope of the var attribute No Page

Example Demonstration

<%@ 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 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 execution result is as follows:

One 
Two 
Three

JSP Standard Tag Library