JSTL - Core <fmt:message> 標籤



<fmt:message> 標籤將鍵對映到本地化訊息並執行引數替換。

屬性

<fmt:message> 標籤具有以下屬性:

屬性 描述 必填 預設值
key 要檢索的訊息鍵 主體
bundle 要使用的資源包 預設包
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:message 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.