返回首页 JSP 教程

JSP 基础教程

JSP 高级教程

JSP 面试问题

JSP 有用的资源

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