Mybatis传入参数为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 ">
即可。