主頁 > 知識庫 > JSP中常用的JSTL fmt(format格式化)標(biāo)簽用法整理

JSP中常用的JSTL fmt(format格式化)標(biāo)簽用法整理

熱門標(biāo)簽:地圖標(biāo)注市場怎么樣 如何用中國地圖標(biāo)注數(shù)字點(diǎn) 好操作的電話機(jī)器人廠家 百度地圖添加標(biāo)注圖標(biāo)樣式 南昌市地圖標(biāo)注app 泰州泰興400電話 怎么申請 聊城智能電銷機(jī)器人外呼 南京新思維電話機(jī)器人 企業(yè)怎么在聯(lián)通申請400電話

JSTL標(biāo)簽提供了對國際化(I18N)的支持,它可以根據(jù)發(fā)出請求的客戶端地域的不同來顯示不同的語言。同時(shí)還提供了格式化數(shù)據(jù)和日期的方法。實(shí)現(xiàn)這些功能需要I18N格式標(biāo)簽庫(I18N-capable formation tags liberary)。引入該標(biāo)簽庫的方法為:
%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
I18N格式標(biāo)簽庫提供了11個(gè)標(biāo)簽,這些 標(biāo)簽從功能上可以劃分為3類如下:
(1)數(shù)字日期格式化。formatNumber標(biāo)簽、formatData標(biāo)簽、parseNumber標(biāo)簽、parseDate標(biāo)簽、timeZone標(biāo)簽、setTimeZone標(biāo)簽。
(2)讀取消息資源。bundle標(biāo)簽、message標(biāo)簽、setBundle標(biāo)簽。
(3)國際化。setlocale標(biāo)簽、requestEncoding標(biāo)簽。
接下將詳細(xì)介紹這些標(biāo)簽的功能和使用方式。

fmt:formatNumber>標(biāo)簽

根據(jù)區(qū)域或定制的方式將數(shù)字格式化成數(shù)字、貨幣或百分比

fmt:formatNumber value="number" [type={number|currency|percent|}]

[pattern="pattern"]

[currencyCode="currencyCode"]

[currentSymbol="currentSymbol"]

[groupingUsec="{true|false}"]

[maxIntergerDigits="maxIntergerDigits"]

[minIntergerDigits="minIntergerDigits"]

[maxFractionDigits="maxFractionDigits"]

[minFractionDigits="minFractionDigits"]

[var="varname"]

[scope="page|request|session|application"]

 />

%@page language="java" contentType="text/html;charset=utf-8"%>
%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
!DOCTYPE html>
html>
  head>
    title>FormatNumber標(biāo)簽使用/title>
  /head>
  body>
    h1>FormatNumber標(biāo)簽使用/h1>
    fmt:setLocale value="fr_fr" />
    France:fmt:formatNumber value="123456789.012"/>
    fmt:setLocale value="zh_cn" />
    China:fmt:formatNumber value="123456789.012"/>
    fmt:setLocale value="de_de" />
    Germany:fmt:formatNumber value="123456789.012"/>
     
  /body>
/html>

fmt:parseNumber />標(biāo)簽

用來將字符串類型的數(shù)字、貨幣、或百分比轉(zhuǎn)換成數(shù)字類型

fmt:parseNumber value="numberString" [type={number|currency|percent|}]

[pattern="pattern"]

[parseLocale="parseLocale"]

[integerOnly="{false|true}"]

[var="varname"]

[scope="page|request|session|application"]

 />

fmt:formatDate />標(biāo)簽

用來將日期類型轉(zhuǎn)換為字符串類型日期

fmt:formatDate value="number" [type={time|date|both}]

[pattern="pattern"]

[dateStyle="{default|short|medium|long|full}"]

[timeStyle="{default|short|medium|long|full}"]

[timeZone="timeZone"]

[var="varname"]

[scope="page|request|session|application"]

 />

fmt:parseDate />標(biāo)簽

用來將字符串類型的時(shí)間或日期轉(zhuǎn)換成日期時(shí)間類型

fmt:parseDate value="date" [type={time|date|both}]

[pattern="pattern"]

[dateStyle="{default|short|medium|long|full}"]

[timeStyle="{default|short|medium|long|full}"]

[timeZone="timeZone"]

[var="varname"]

[scope="page|request|session|application"]

 />

fmt:setTimeZone />標(biāo)簽

用來設(shè)置默認(rèn)時(shí)區(qū)或?qū)r(shí)區(qū)存儲到屬性范圍中

復(fù)制代碼 代碼如下:

fmt:setTimeZone value="timezone" [var="varname"] [scope="{page|request|session|application}"] />

fmt:timeZone />標(biāo)簽
用來暫時(shí)的設(shè)定時(shí)區(qū)
fmt:timeZone value="timeZone">

本體內(nèi)容

/fmt:timeZone>

fmt:setLocale />標(biāo)簽

用來設(shè)定用戶的區(qū)域語言

復(fù)制代碼 代碼如下:

fmt:setLocale value="locale" [variant="variant"] [scope="{page|request|session|application}"] />

fmt:requestEncoding />標(biāo)簽
設(shè)定接收的字符串的編碼格式
fmt:requestEncoding value="charsetName" />

fmt:setBundle />標(biāo)簽

用來設(shè)定默認(rèn)的數(shù)據(jù)來源,也可以將其存儲到一定范圍中,供需要時(shí)使用

復(fù)制代碼 代碼如下:

fmt:setBundle basename="basename" [var="varname"] [scope="{page|request|session|application}"] />

fmt:message />標(biāo)簽

用來從指定的資源文件中通過索引取得值

復(fù)制代碼 代碼如下:

fmt:message key="messageKey" [bundle="resourceBundle"] [var="varname"] [scope="{page|request|session|application}"] />

fmt:param />標(biāo)簽

用來傳遞參數(shù)(在從資源文件中取得信息時(shí),可能需要動態(tài)設(shè)定參數(shù)的情況下)

fmt:param value="messageParameter" />

沒有本體內(nèi)容

fmt:param value="messageParameter" >有本體內(nèi)容

參數(shù)

/fmt:param>

fmt:bundle />標(biāo)簽

用來設(shè)定數(shù)據(jù)來源

fmt:bundle basename="basename" [prefix="prefix"] >

本體內(nèi)容fmt:message>

/fmt:bundle>

您可能感興趣的文章:
  • JSP自定義標(biāo)簽Taglib實(shí)現(xiàn)過程重點(diǎn)總結(jié)
  • jsp struts1 標(biāo)簽實(shí)例詳解
  • jsp頁面中如何將時(shí)間戳字符串格式化為時(shí)間標(biāo)簽
  • JSP自定義標(biāo)簽rtexprvalue屬性用法實(shí)例分析
  • jsp自定義標(biāo)簽用法實(shí)例詳解
  • JSP頁面中如何用select標(biāo)簽實(shí)現(xiàn)級聯(lián)
  • JSP自定義分頁標(biāo)簽TAG全過程
  • Jsp自定義標(biāo)簽和方法詳解

標(biāo)簽:自貢 白銀 銅川 開封 吉林 山南 烏蘭察布 臨汾

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《JSP中常用的JSTL fmt(format格式化)標(biāo)簽用法整理》,本文關(guān)鍵詞  JSP,中常,用的,JSTL,fmt,format,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《JSP中常用的JSTL fmt(format格式化)標(biāo)簽用法整理》相關(guān)的同類信息!
  • 本頁收集關(guān)于JSP中常用的JSTL fmt(format格式化)標(biāo)簽用法整理的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章