Mybatis用if判断int类型参数为0会过滤

例子

当下列sql传入0时,通过if判断会自动跳过

delete from message_logging where 1=1
<if test="param1.sceneType != null and param1.sceneType != ''">
    and scene_type = #{paramCondition.sceneType}
</if>

分析

原因在于判断!=''这个条件时OGNL会返回''的长度,因此!=''会变成!=0来判断

posted @ 2022-02-10 17:16  Frank_Z9  阅读(329)  评论(0)    收藏  举报