<fmt:message> 标签

<fmt:message>标签映射一个关键字给局部消息,然后执行参数替换。

 

属性

<fmt:message>标签有如下属性:

属性 描述 是否必要 默认值
key 要检索的消息关键字 Body
bundle 要使用的资源束 默认资源束
var 存储局部消息的变量名 Print to page
scope var属性的作用域 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.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