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; 大于号>

posted @ 2019-03-18 10:02  陆伟  阅读(36066)  评论(0编辑  收藏  举报