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
jsp_standard_tag_library.htm
广告
© . All rights reserved.