为所有jsp页面设置默认的fmt formatNumber maxFractionDigits [英] Setting default fmt formatNumber maxFractionDigits for all jsp pages

查看:201
本文介绍了为所有jsp页面设置默认的fmt formatNumber maxFractionDigits的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使以下标记始终显示5个小数位?

Is it possible to have the following tag always display 5 decimal places?

<fmt:formatNumber type="currency" value="${number}" />

无需将其更改为

<fmt:formatNumber type="currency" maxFractionDigits="5" value="${number}" />

基本上,我有很多这样的东西,我希望它们全部更改,我希望将5个小数位设置为默认值.

basically I have so many of these and I want them all to change, I want 5 decimal places to be the default.

推荐答案

是.您可以通过扩展fmt:formatNumber功能来实现此目的.

Yes. You cam implement this by extending fmt:formatNumber functionality.

为此,创建一个扩展org.apache.taglibs.standard.tag.rt.fmt.FormatNumberTag的类,以将 maxFractionDigits 默认设置为5(未提供时).

For this, create a class extending org.apache.taglibs.standard.tag.rt.fmt.FormatNumberTag to set maxFractionDigits to 5 by default (when not supplied).

您还需要更改fmt标签库描述符(tld)文件中的引用,以指向您自己的实现.

You would also need to change the reference in your fmt tag library descriptor (tld) file to point to your own implementation.

默认情况下,这些应该存在于WEB-INF\lib中的jstl jar中.

These should be present in your jstl jar located in WEB-INF\lib by default .

编辑:就个人而言,我会尽可能使用Adeel的方法来设置自定义语言环境.

Personally, I would go for Adeel's approach of setting up a custom locale, if at all possible.

这篇关于为所有jsp页面设置默认的fmt formatNumber maxFractionDigits的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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