Mybatis sql if 判断条件中,如果是单个的字符,需要将其转化为String,使用toString()方法,否则“==”判断条件始终不能成立,如下代码示例:
<if test="state !=null and state != '' ">
<if test="state=='2'.toString()">
and ob1.pk_id is not null
</if>
<if test="state!='2'.toString()">
and ob1.pk_id is null
</if>
</if>