最近在做项目过程中,需要通过时间范围条件查询结果列表,代码如下:
<if test="createStartTime!=null and createStartTime!=''">
<![CDATA[ AND DATE_FORMAT(create_date, '%Y-%m-%d %h:%i:%s') >= #{createStartTime} ]]>
</if>
<if test="createEndTime!=null and createEndTime!=''">
<![CDATA[ AND DATE_FORMAT(create_date, '%Y-%m-%d %h:%i:%s') <= #{createEndTime} ]]>
</if>
大于号和小于号在mybatis中不起作用,所以要转换一下.或者使用转义符。
<if test="excTimeLength != null">
and dl.exc_time_length >= #{excTimeLength,jdbcType=INTEGER}
</if>
<小于号 < > 大于号>