作为每documentation,所述fn:length()
仅适用于String
(这将返回String#length()
方法的值)和上Collection
(这将返回Collection#size()
方法的值)。
但是,您好像要通过号码。一个整数或其他东西。 fn:length()
不适用于数字,并且总是会给出false
,而不考虑数字的值。
如果您要检查,如果事情是null
,那么就这样做:
<c:choose>
<c:when test="${studentData.rollNumber == null}">Found Nothing</c:when>
<c:otherwise>Found something</c:otherwise>
</c:choose>
或者,如果你想检查数的值是0
,然后就去做
请注意,empty
检查工作同样好,这是无论它是一个数字,字符串或集合。任何是null
或fn:length()
的0
将评估true
。
<c:choose>
<c:when test="${empty studentData.rollNumber}">Found Nothing</c:when>
<c:otherwise>Found something</c:otherwise>
</c:choose>
你也可以使用'$ {空studentData.rollNumber}'。 – BalusC 2011-06-07 19:46:49