码上敲享录 > freemarker常见问题解答 > ftl页面报错The only legal comparisons are between two numbers, two strings, or two dates

ftl页面报错The only legal comparisons are between two numbers, two strings, or two dates

上一章章节目录下一章 2017-12-14已有5751人阅读 评论(0)

ftl页面报错The only legal comparisons are between two numbers, two strings, or two dates

在freemarker的ftl页面中if标签常常会报freemarker.template.TemplateException: The only legal comparisons are between two numbers, two strings, or two dates.的错误。

例如

<#if 1=="${1?if_exists?html}"></#if>这句话就会报错,因为1是int类型,"${1?if_exists?html}"是字符串,不同类型比较失败。

解决方法:把int类型转成字符串即可。修改如下:

<#if "1"=="${1?if_exists?html}"></#if>

<#if "${1?if_exists?html}"=="${1?if_exists?html}"></#if>

本文地址:http://yayihouse.com/yayishuwu/chapter/1066


0

有建议,请留言!

  • *您的姓名:

  • *所在城市:

  • *您的联系电话:

    *您的QQ:

  • 咨询问题:

  • 提 交