posts - 325,  comments - 25,  trackbacks - 0
I18N库主要完成:
    1.web应用程序的国际化
    2.消息、日期的格式化
1.<fmt:formatNumber>:在jsp页面中格式化数字
        <fmt:formatNumber 
                var="存放结果的变量"
                value="将被格式化的数字"
                scope="范围"
                type="number/currency/percent"//数字,货币,百分比
                currencyCode="cny/usd" //cny:人民币 usd:美元
                currencySymbol="羊/$" //标准货币符号
                groupingUsed="true/false" //是否将数字进行区隔 如:123,456,00
                maxFractionDigits="最多小数位数"
                maxIntegerDigits="最多整数位数"
                minFractionDigits="最少小数位数"
                minIntegerDigits="最少整数位数"
                pattern="格式化数字用的样式" //如:####.##
    />
        eg:
            <fmt:formatNumber var="result" value="6789.3581" type="currency" maxFractionDigits="2" groupingUsed="true"/>
            <c:out value="${result}"/> :6,789.36
2.<fmt:parseNumber>:在jsp页面中实现将字符串形式的数字、货币、百分比转换成数字
        <fmt:parseNumber
                var="存放转换结果的变量"
                value="将转换的值"
                scope="范围"
                type="number/currency/percent"
                parseLocale="zh_CN,en"//语言地区代码
                integerOnly="true/false"是否只显示整数部分
                pattern="$$$$.$$"//格式化数字所用的样式
        />
        eg:
         <fmt:parseNumber var="result" value="yang 6789.36" type="currency"/>   输出结果为:6789.36
         <fmt:parseNumber var="result" value="78.90%" type="percent"/>             输出结果为:0.789
3.<fmt:formatDate>:在jsp页面中实现格式化日期和时间
        <fmt:formatDate
            var="存放格式化结果的变量"
            value="将被格式化的日期或时间"
            scope="page/request/session/application"
            type="time/date/both" //time:时间 date:日期 both:时间和日期
            dateStyle="default/short/medium/logn/full"  //日期的显示方式
            timeStyle="default/short/medium/logn/full"  //时间的显示方式            
            timeZone="CST" 设置时区:CST:中部标准时间
            pattern="yyyy 年MM 月dd日 hh:mm:ss"
        </fmt:fomatDate>
4.<fmt:parseDate>:将字符串形式的时间和日期转换成日期时间类型
       <fmt:parseDate
                var="varName"
                value="value"
                scope="request"
                type="time/date/both"
                dateStyle="default/short/medium/long/full"
                timeStyle="default/short/medium/long/full"
                timeZone="timeZone"
                pattern="pattern"/>
        eg:
        <c:set var="now" value="2008-05-26 11:04:00"/>
        <fmt:parseDate var="result" value="{now}" type="both"/>
        <c:out value="${result}"/>   
5.<fmt:setLocale>
      <fmt:setLocale value="zh_CN,en" //语言地区码
                              variant="浏览器类型" // Win,Mac
                               scope="request等"/>
6.<fmt:setBundle>:设置默认消息资源
       <fmt:setBundle basename="basename"// 资源名称,如:MessageResource
                               var="存放资源文件名称的变量"
                               scope="request"/>
    eg:
        <fmt:setLocale value="zh_CN"/>
        <fmt:setBundle basename="MessageResource"/>//假如有一个MessageResource.properties信息资源文件
7.<fmt:message>:在指定的消息资源文件中按关键字取出相应的消息内容
    <fmt:message key="messageKey"/>
     eg:
            <jsp:useBean id="now" class="java.util.Date"/>
            <fmt:formatDate value="${now} var="result"/>
            <fmt:setLocale value="zh_CN"/>
             <fmt:setBundle basename="MessageResource"/>
             <fmt:message key="hello">
                    <fmt:param value="lhb"/>
            </fmt:message>
            <fmt:message key="today">
                    <fmt:param value="${result}"/>
            </fmt:message>
posted on 2008-05-26 11:21 长春语林科技 阅读(804) 评论(0)  编辑  收藏 所属分类: jstl

只有注册用户登录后才能发表评论。


网站导航:
 
<2008年5月>
27282930123
45678910
11121314151617
18192021222324
25262728293031
1234567

 

长春语林科技欢迎您!

常用链接

留言簿(6)

随笔分类

随笔档案

文章分类

文章档案

相册

收藏夹

搜索

  •  

最新评论

阅读排行榜

评论排行榜