mybatis 大于小于特殊处理

使用 CDATA 原样输出

  <select id="getUserList" resultMap="ResultMapExt" >
    select u.user_id, u.user_name,u.real_name,u.user_description,r.level,u.phone,u.email,u.create_time,u.user_status
    from  user u
    left join role r on r.role_id=u.role_id
    where 1=1
    and ifnull(user_status,0)!=1
    <if test="userName != null and userName != ''">
      <bind name="userName" value="'%' + _parameter.userName + '%'"/>
      and u.user_name like #{userName}
    </if>
    <if test="level != null ">
      and r.level = #{level}
    </if>
    <if test="startTime != null and startTime != ''">
      and u.create_time <![CDATA[ >=]]> #{startTime}
    </if>
    <if test="endTime != null and endTime != ''">
      and u.create_time <![CDATA[<=]]> #{endTime}
    </if>
    order by u.user_id desc
  </select>

使用&gt;=或者&lt;=替代

  <select id="getUserList" resultMap="ResultMapExt" >
    select u.user_id, u.user_name,u.real_name,u.user_description,r.level,u.phone,u.email,u.create_time,u.user_status
    from  user u
    left join role r on r.role_id=u.role_id
    where 1=1
    and ifnull(user_status,0)!=1
    <if test="userName != null and userName != ''">
      <bind name="userName" value="'%' + _parameter.userName + '%'"/>
      and u.user_name like #{userName}
    </if>
    <if test="level != null ">
      and r.level = #{level}
    </if>
    <if test="startTime != null and startTime != ''">
      and u.create_time  &gt;= #{startTime}
    </if>
    <if test="endTime != null and endTime != ''">
      and u.create_time &lt;= #{endTime}
    </if>
    order by u.user_id desc
  </select>