Struts 2 中的格式编号 <s:property/>标签 [英] Format number in Struts 2 &lt;s:property/&gt; tag

查看:26
本文介绍了Struts 2 中的格式编号 <s:property/>标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想格式化 Struts 2 中 <s:property value="summary.total"/> 标签显示的数字.有一个 double 值.我怎样才能做到这一点?我应该使用OGNL吗?

或者我必须使用 <s:text/> 标签并在资源文件中定义我的格式?

解决方案

你需要使用 代码>.

属性文件:

<块引用>

summary.cost= € {0,number,##0.00}

JSP:

<s:param name="value" value="summary.total"/></s:text>

这个答案解释了如何使用#0 在格式掩码中.

I would like to format number displayed by <s:property value="summary.total"/> tag in Struts 2. There is a double value. How can I do that? Should I use OGNL?

Or maybe I must use <s:text/> tag and define my format in resuource file?

解决方案

You need to use <s:text/> with <s:param/>.

Property file:

summary.cost= € {0,number,##0.00}

JSP:

<s:text name="summary.cost"> 
    <s:param name="value" value="summary.total"/> 
</s:text>

This answer explains how to use # and 0 in the format mask.

这篇关于Struts 2 中的格式编号 <s:property/>标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆