<fmt:setBundle>
《fmt:setBundle》标记用于加载资源包并将其存储在指定的范围变量或包配置变量中。
属性 (Attribute)
《fmt:setBundle》标记具有以下属性 -
属性 | 描述 | 需要 | 默认 |
---|---|---|---|
basename | 要作为作用域或配置变量公开的资源包系列的基本名称 | Yes | None |
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:setBundle 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