<Fmt: message> tag
<Fmt: message> tag to map a key to the local news, and then perform the replacement parameters.
Syntax
<fmt:message key="<string>" bundle="<string>" var="<string>" scope="<string>"/>
Attributes
<Fmt: message> tag has the following attributes:
Attributes | description | If necessary | Defaults |
---|---|---|---|
key | To retrieve the message key | no | Body |
bundle | To use the resource bundle | no | The default resource bundle |
var | Variable name stores local news | no | Print to page |
scope | Scope var attribute | 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:message 标签</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