<fmt:message>标签映射键到本地化消息和参数进行更换。
<fmt:message>标签具有以下属性:
属性 | 描述 | 必须 | 默认 |
---|---|---|---|
key | 消息键用来检索 | No | Body |
bundle | 资源包使用 | No | Default bundle |
var | 变量名称来存储本地化消息 | No | Print to page |
scope | 存储本地化消息的变量范围 | No | Page |
<%@ 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.yiibai.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>这将产生以下结果:
One Two Three