如何解决mybatis在xml中传入Integer整型参数为0时查询条件失效问题?【亲测有效】

今天遇到个问题,接口入参Integer类型,mybatis传入0老是显示没传入参数,传入其他1,2等值正常;

解决办法:
1. 传参有Integer改成String
2. 去掉mybatis中 做法:去掉【status != ‘’】 的这条非空判断

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

修改成

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

参考

猜你喜欢

转载自blog.csdn.net/qq_40985985/article/details/126888382
今日推荐