mybaitis传参数问题2:int类型,值为0的坑

例如传入的参数为type,类型为int,值为0。当我们用判断语句时

<if test="type != null and type != ''"> and type= #{type } </if>

由于type 的值为0,在执行判断时,会将type !=''这个条件判断为false,那么将不会执行判断中的 and type= #{type } 语句。

所以在有int类型时,我们直接将判断语句写成

<if test="type != null ">

即可。

posted @ 2022-08-12 16:55  南翔技校毕业后  阅读(74)  评论(0)    收藏  举报