How to find length of an integer in JSP?

半世苍凉 提交于 2019-12-24 00:58:34

问题


I can use fn:length(mystring) to find the length/number of character of a string.

How can I find the length/number of digits in an integer?

e.g. if my int is 3000, I want to return 4.


回答1:


Convert it to String first by evaluating it as body of <c:set>:

<c:set var="intAsString">${someInt}</c:set>

Then you can get its length the usual way:

${fn:length(intAsString)}


来源:https://stackoverflow.com/questions/10343203/how-to-find-length-of-an-integer-in-jsp

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