Struts2 -- 格式化输出 date,money

Struts 2里已经有支持格式化输出的tag, 使用它需要这些步骤:

1. 增加国际化支持

  在Struts.xml 增加这一行  <constant name="struts.custom.i18n.resources" value="globalMessages" /> 

  资源文件可以放在globalMessages里 (globalMessages_zh_CN.properties, globalMessages_en_US.properties)

  

  global.format.date={0,date,yyyy-MM-dd}
  global.format.money={0,number,RMB\#\#0.00 '元'}
  order.orderCode=订单代码

 

2. Jsp 使用

    1) <%@ taglib uri="/struts-tags" prefix="s"%>

    2)  label显示<s:text name="order.orderCode"/>

    3) date格式化显示

        <s:text name="global.format.date"><s:param value="orderdate"></s:param></s:text>

        global.format.date 是国际化资源文件里配置的, orderdate是action里的属性(也可以pojo类的属性)

                       这样日期就会按配置的格式显示。

 

转载于:https://www.cnblogs.com/tyler2000/archive/2011/01/18/1938527.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值