Name | Required | Type | Description |
baseName | True | java.lang.String | Resource bundle’s fully qualified name. Follows the Java’s fully qualified class name convention (‘.’ is used to separate the package names). |
prefix | False | java.lang.String | When used with <fmt:message> this attribute specifies the value to be prepended in the key value so that each time we do not have to provide the prefix repeatedly. |
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title><fmt:bundle> Demo</title> </head> <body> <h1><fmt:bundle> Demo</h1> <fmt:bundle basename="net.codejava.jstl.messages"> <fmt:message key="codejava.welcome.text"/><br/> <fmt:message key="codejava.description.text"/> </fmt:bundle> <br/><br/> <p>With prefix</p> <br/> <fmt:bundle basename="net.codejava.jstl.messages" prefix="codejava."> <fmt:message key="welcome.text"/><br/> <fmt:message key="description.text"/> </fmt:bundle> </body> </html>Note that the first time we have not used the prefix attribute hence we needed to specify the full key name to display our messages. To avoid this in the next example we specified the prefix.
The above example loads a resource bundle messages.properties using the tag <fmt:bundle> located in the package net.codejava.jstl and displays two messages using the <fmt:message> tag.
formatDate | formatNumber | message | param | parseDate | parseNumber | requestEncoding | setBundle | setLocale | setTimeZone | timeZone