问题:两变量比较大小报错
<#if db.s > 1>
出现异常 java.lang.RuntimeException: {"msg":"解析freemarker失败Can't compare values of these types. Allowed comparisons are between two numbers, two strings, two dates, or two booleans.\nLeft hand operand is a string (wrapper: f.t.SimpleScalar).\nRight hand operand is a number
解决方案:从字面意思来看是比较符号两边类型不一致,但是奇怪的是其实db.s是我上一个sql的select count(1) as s from t,我自以为count是数值类型了,至于为啥不是数值类型,我不去做深究。最后的解决方法是<#if db.s?default("0")?number gt 1> 解决了问题。