在Freemarker中将带逗号的字符串转换为整数 [英] Convert string with commas into integer in Freemarker

查看:117
本文介绍了在Freemarker中将带逗号的字符串转换为整数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的字符串之间有逗号。我该如何将此字符串转换为整数。我尝试使用

I have a string with commas in between. How should I convert this string into an integer. I tried using

x?number

但是这给了我以下错误

Exceptionfreemarker.core.NonNumericalException

例如字符串是453,000。我需要将其转换为453000。

e.g. The string is "453,000". I need to convert this to 453000.

还有其他方法吗?

推荐答案

内置的功能无法解析国家格式的数字。 ?number 仅处理计算机格式,因为当数字作为字符串传输时(应该很少),这就是以前使用的。所以原则上 x 在到达FreeMarker时应该已经是一个数字,或者至少它应该使用计算机格式。如果那是不可能的,那么你将需要一个自定义函数(或方法)。

There's no function built in for parsing numbers with national formats. ?number only deals with computer format, because when numbers are transferred as strings (which should be already rare), that's what used to be used. So in principle x should be already a number when it gets to FreeMarker, or at least it should use computer format. If that's not possible, you will need a custom function (or method) for that.

这篇关于在Freemarker中将带逗号的字符串转换为整数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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