Convert string with commas into integer in Freemarker

自闭症网瘾萝莉.ら 提交于 2019-12-13 22:13:13

问题


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

x?number

but that gives me the following error

Exceptionfreemarker.core.NonNumericalException

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

Is there any other way of doing this?


回答1:


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.



来源:https://stackoverflow.com/questions/39838953/convert-string-with-commas-into-integer-in-freemarker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!