[英]How to use the value returned by formatNumber in a String comparison
I got this line to format a number : 我得到这行来格式化数字:
<fmt:formatNumber type="number" pattern="###,#######" value="1234567890" var="test"/>
Above line output 123 4567890
with my current locale (french). 在行输出123 4567890
,显示我当前的语言环境(法语)。
If I use below code : 如果我使用以下代码:
<c:set var="ref" value="123 4567890"/> ${ref == test}
It return false, why? 它返回false,为什么?
First, I thought that test
was no a String hence I tried that : 首先,我认为test
不是String,因此我尝试了:
<c:set var="test2" value="${test}"/>
But ${ref == test2}
still return false. 但是${ref == test2}
仍然返回false。
Looks like the French locale uses a non-breaking space character (the " ", hex 0xA0 (160 decimal)), but you were using a regular space (character 32) 看起来法国语言环境使用了不间断的空格字符(“&nbsp”,十六进制0xA0(160个十进制)),但是您使用的是常规空格(字符32)
This should print true : 这应该打印true :
<fmt:formatNumber type="number" pattern="###,#######" value="1234567890" var="test"/>
<% pageContext.setAttribute("nbsp", String.valueOf('\u00a0'));%>
<c:set var="ref" value="123${nbsp}4567890"/>
ref is ${ref} <br />
test is ${test} <br />
${ref == test}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.