JSTL Core < fmt:message > 标签
<fmt:message>
标签将键映射到本地化的消息中并执行参数替换。
属性:
<fmt:message>
标签具有如下所示属性:
属性 | 描述 | 是否必需 | 默认值 |
---|---|---|---|
key | 要检索的消息键 | 否 | Body |
bundle | 使用的资源包 | 否 | 默认包 |
var | 存储本地化消息的变量名 | 否 | 页面输出 |
scope | 存储本地化消息的变量范围 | 否 | 页面 |
实例:
<%@ 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.tutorialspoint.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