<fmt:message>
《fmt:message》标记将键映射到本地化消息并执行参数替换。
属性 (Attribute)
《fmt:message》标记具有以下属性 -
属性 | 描述 | 需要 | 默认 |
---|---|---|---|
key | 要检索的消息密钥 | No | Body |
bundle | 要使用的资源包 | No | 默认捆绑 |
var | 用于存储本地化消息的变量的名称 | No | 打印到页面 |
scope | 用于存储本地化消息的变量的范围 | No | Page |
例子 (Example)
<%@ 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.iowiki.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