当前位置: 代码迷 >> J2EE >> struts2 s:property如何输出百分比数字
  详细解决方案

struts2 s:property如何输出百分比数字

热度:26   发布时间:2016-04-22 01:41:52.0
struts2 s:property怎么输出百分比数字
从action中接受一个long格式的数字 ,在界面上怎么用百分比现实

------解决方案--------------------
在资源文件中定义日期及其数字的格式化,例如在classpath下新建一个.properties文件,起名为format.properties,内容如下
format.percent = {0,number,##0.00'%'}

用<s:text>进行引用
<s:i18n name="format">
<s:text name="format.percent " >
<s:param value="longValue"></s:param>
</s:text>
</s:i18n>

参见
http://www.blogjava.net/keweibo/articles/174997.html
struts2的匹配模式详情请见
http://java.sun.com/docs/books/tutorial/i18n/format/decimalFormat.html
------解决方案--------------------
探讨
在资源文件中定义日期及其数字的格式化,例如在classpath下新建一个.properties文件,起名为format.properties,内容如下
format.percent = {0,number,##0.00'%'}

用 <s:text>进行引用
            <s:i18n name="format">
                <s:text name="format.percent " >
                    <s:param value="longValue"> </s:param>   
                </s:text>
            </s:i18n>

参见
http://www.blogjava.net/keweibo/articles/174997.html
struts2的匹配模式详情请见
http://java.sun.com/docs/books/tutorial/i18n/format/decimalFormat.html

------解决方案--------------------
不管是struts2还是JSTL都有专门的格式化标签
  相关解决方案