JSTL Core < fmt:setBundle > 标签
<fmt:setBundle>
标签用于加载资源包,并把它存储在已命名的给定范围的变量中或存储在包配置变量中。
属性:
<fmt:setBundle>
标签具有如下所示属性:
属性 | 描述 | 是否必需 | 默认值 |
---|---|---|---|
basename | 资源包家族的基本名称,作为一个给定范围的变量或配置变量来显示 | 是 | 无 |
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:setBundle 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