关于mybatis使用map传参0和 " !='' " 的问题

2022-10-22,,,

记录一下我在开发中遇到的一个小问题:

  dao中有一个接口的传入类型为map:public abstract list<activityentrydo> selectbydemocconditionasc(map<string, object> parammap);

  我在service调用该接口时,有一个参数为int类型且值为0,对应的sql中有一个判断:

  <if test="checkstatus != null and checkstatus != '' ">
                and t.check_status in
                <foreach collection="checkstatus" index="index" item="item"
                            open="(" separator="," close=")">
                            #{item}
                        </foreach>
         </if>

  以为会将0作为条件查询,然后log打印出的sql中并没有该参数,诧异!!!!!!

  解决方案:将参数作为string传入即可解决。

       参考文章:https://blog.csdn.net/bei_fang_du_lang/article/details/79093217,如有侵权,请联系我删除!

  注:首次写博,不喜勿喷。

  

《关于mybatis使用map传参0和 " !='' " 的问题.doc》

下载本文的Word格式文档,以方便收藏与打印。