1.判断String是否为空
<if test="stringParam != null and stringParam != ''"></if>
脚本中:+"<if test='keyword != null and keyword!=\"\"'>"
"<if test=\"age != null\"> age = #{age}</if>" +
2.判断Integer是否大于0
<if test="idParam !=null and idParam gt 0"></if>
判断等于 <when test=\"item.mark == 1\">"
3.判断List是否不为空
<if test="listParam !=null and listParam.size >0"></if>
4.判断String是否以某特定字符(比如此处的"user")开头
<if test="stringParam.indexOf('user') != -1"></if>
5.判断字符串是否等于特定字符(比如此处的user)
<if test='stringParam != null and stringParam == "user"'></if>
注意不能使用此写法 <if test="stringParam != null and stringParam != 'user'"></if> 即最外边用双引号,里边用单引号,此写法会抱java.lang.NumberFormatException异常
如果要用这个写法要<if test="stringParam != null and stringParam != 'user'.toString()"></if>
6 日期比较
and apply_start_time >=#{minDate,jdbcType=TIMESTAMP}
7 like 的三种写法
方法一:concat and name like concat('%',#{name},'%')
方式二:${} and exam_type_name like '%${examTypeName}%'
方式三:#{} and exam_type_name like "%"#{examTypeName}"%"
8 比较符号
原符号 < <= > >= & ' "
替换符号 < <= > >= & ' "
例如:sql如下:
create_date_time >= #{startTime} and create_date_time <= #{endTime}
大于等于
<![CDATA[ >= ]]>
小于等于
<![CDATA[ <= ]]>
例如:sql如下:
create_date_time <![CDATA[ >= ]]> #{startTime} and create_date_time <![CDATA[ <= ]]> #{endTime}