<FMT:setBundle>一样标签用于加载在指定范围的变量或束配置变量的资源束,并将其存储。
<FMT:setBundle>一样标签具有以下属性-
| 属性 | 描述 | 需要 | 默认 |
|---|---|---|---|
| 基本名 | 资源包家族的基本名称,以作用域或配置变量形式公开 | 是 | 没有 |
| 变种 | 存储新捆绑包的变量名称 | 没有 | 取代预设 |
| 范围 | 存储新捆绑软件的变量范围 | 没有 | 页 |
<%@ 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.nhooo.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