1. 程式人生 > >Mybatis的if test字串比較

Mybatis的if test字串比較

第一種解決方法:

<if test="isExpired=='Y'">
and msg.expire_time &lt; now()
</if>

會報NumberFormatException,這樣就可以了。

<if test="isExpired=='Y'.toString()">
and msg.expire_time &lt; now()
</if>

第二種解決方法:

<if test=" name=='張三' ">

<if>

這樣會有問題,換成

<if test=' name=="張三" '>

<if>