mybatis if test 之 0当做参数传入出问题

mybatis的参数传入为Integer的0的时候会把0当做空处理掉

要判断0必须写成下面这样

 <where>  
            <if test="name!=null and name!=''">  
            AND mi.name like CONCAT('%',#{name},'%')  
            </if>  
            <if test="telephone!=null and telephone!=''">  
            AND mi.telephone = #{telephone}  
            </if>  
            <if test="status!=null and status!='' or 0 == status">  
            AND rs.status = #{status}  
            </if>  
            <if test="applicationTimeStart!=null and applicationTimeEnd!=null">  
            and rs.update_time >= #{applicationTimeStart} and rs.update_time <  
            DATE_ADD(#{applicationTimeEnd},INTERVAL 1 DAY)  
            </if>  
        </where>  
       

如果传入的参数是String字符串的0,则不需要加 or 0==status

猜你喜欢

转载自blog.csdn.net/qq_39940205/article/details/84776824