更新时间:2022-06-21 04:53:39
找到解决方案.我需要在标记属性中明确声明类型,例如:
Solution found. I needed to explicitly declare the type on my tag attributes, like:
<%@ attribute name="currentPage" required="true" type="java.lang.Long" %>
<%@ attribute name="totalPages" required="true" type="java.lang.Long" %>
我怀疑没有声明的类型,两个属性都被解释为字符串,并且标签在数字的字符串值之间进行了字典比较.我认为文字值10
是有效的,因为JSP解释器将其识别为适当的数字类型,然后自动将比较中的另一个参数转换为匹配.
I suspect that without the declared type both attributes were being interpreted as Strings, and the tag was doing a lexicographical comparison between the string values of the numbers. I assume a literal value of 10
worked because the JSP interpreter recognized it as a proper numerical type and then automatically converted the other argument in the comparison to match.
长话短说,请始终在标签属性上声明type
.否则会发生令人困惑的事情.
So long story short, always declare a type
on your tag attributes. Otherwise very confusing things can happen.