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.