法1:
正确:
<if test='activityBean.searchForce=="N" '>错误:
<if test="activityBean.searchForce=='N' ">
因为java是强类型语言,单引号表示char类型,只能赋给一个字符给char类型,
而双引号则表示String类型
法2:
<if test="isExpired=='Y'">
and msg.expire_time < now()
</if>
会报NumberFormatException,这样就可以了。
<if test="isExpired=='Y'.toString()">and msg.expire_time < now()
</if>
法3:
<if test='verityFailureMark eq "1"'>
theaterLocation='1'
</if>
<if test='verityFailureMark eq "2"'>
ONELINELOCATION='1'
</if>
本文详细解析了MyBatis中ifTest标签的使用方法,对比了不同条件表达式的写法及其适用场景,强调了字符串与字符类型的区别,并通过实例展示了如何正确配置条件判断。
8万+

被折叠的 条评论
为什么被折叠?



