亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

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

 更新時間:2016年04月14日 15:46:44   作者:張大鵬  
這篇文章主要介紹了JSP中常用的JSTL fmt(format格式化)標(biāo)簽用法整理,fmt的格式化處理遵循i18n國際化格式標(biāo)準(zhǔn),需要的朋友可以參考下

JSTL標(biāo)簽提供了對國際化(I18N)的支持,它可以根據(jù)發(fā)出請求的客戶端地域的不同來顯示不同的語言。同時還提供了格式化數(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個標(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)簽

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

<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)時區(qū)或?qū)r區(qū)存儲到屬性范圍中

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

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

<fmt:timeZone />標(biāo)簽
用來暫時的設(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ù)來源,也可以將其存儲到一定范圍中,供需要時使用

復(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ù)(在從資源文件中取得信息時,可能需要動態(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>

相關(guān)文章

最新評論