如何將鍵與本地化資訊對應,並在 JSP 中執行引數替換?


<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

更新於: 30-Jul-2019

151 瀏覽

啟動您的 職業生涯

完成課程即可獲得認證

開始
廣告