<fmt:message> 标签

JSP 标准标签库JSP 标准标签库

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

语法格式

<fmt:message
 key="<string>"
 bundle="<string>"
 var="<string>"
 scope="<string>"/>

属性

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

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


实例演示

<%@ page language="java" contentType="text/html; charset=UTF-8"
 pageEncoding="UTF-8"%>
<%@ 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 标签</title>
</head>
<body>
<fmt:setLocale value="en"/>
<fmt:setBundle basename="com.icodebang.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

JSP 标准标签库JSP 标准标签库

0 个评论

要回复文章请先登录注册