当前位置: 代码迷 >> Web前端 >> freemarker中 The only legal comparisons are between two . 有关问题解决
  详细解决方案

freemarker中 The only legal comparisons are between two . 有关问题解决

热度:597   发布时间:2012-07-01 13:15:00.0
freemarker中 The only legal comparisons are between two .. 问题解决

最近在用freemarker的时候碰到一个问题,在<#list>中的元素用<#if>进行比较

<#if category.categoryId==categoryId>

结果出现问题如下:

freemarker.template.TemplateException: The only legal comparisons are between two numbers, two strings, or two dates.
Left  hand operand is a freemarker.template.SimpleNumber
Right hand operand is a freemarker.template.SimpleScalar
其原因为左边与右边的类型不一样,将它们类型转换成一样就OK了

?

?

?

?