mybatis时间范围查询

     <if test="excStartTime!=null and excStartTime!=''">
                <![CDATA[   and DATE_FORMAT(dl.exc_start_time, '%Y-%m-%d')>=  DATE_FORMAT(#{excStartTime}, '%Y-%m-%d')   ]]>
        </if>
        <if test="excEndTime!=null and excEndTime!=''">
            <![CDATA[  and DATE_FORMAT(dl.exc_end_time, '%Y-%m-%d') <= DATE_FORMAT(#{excEndTime}, '%Y-%m-%d')    ]]>
        </if>
    

大于号和小于号在mybatis中不起作用,所以要转换一下.

或者使用转义符.

 <if test="excTimeLength != null">
       and dl.exc_time_length &gt;= #{excTimeLength,jdbcType=INTEGER}
      </if>

&lt;小于号  <      &gt; 大于号>

原文地址:https://www.cnblogs.com/bulrush/p/10550529.html