0
点赞
收藏
分享

微信扫一扫

Mysql相关知识点

一脸伟人痣 2023-07-28 阅读 88

为什么不能正确识别值为0的参数?

mybatis中的自己写的判断方法

            <if test="searchForm.buildingType != null and searchForm.buildingType !=''">
                and a.building_type=#{searchForm.buildingType}
            </if>

mybatis源码是这样的:

return s.length() == 0 ? 0.0D : Double.parseDouble(s);

参数为0,则0 == 0.0D 相等 ,就进不去if里面了

怎么解决这个问题?

添加or条件

            <if test="searchForm.buildingType != null and searchForm.buildingType !='' or searchForm.buildingType==0">
                and a.building_type=#{searchForm.buildingType}
            </if>
举报

相关推荐

0 条评论