MyBatis Mapper judgment writing

1. Determine whether the String is empty

<if test="stringParam != null and stringParam != ''"></if>

2. Determine whether Integer is greater than 0

<if test="idParam !=null and idParam gt 0"></if>

3. Determine whether the List is not empty

<if test="listParam !=null and listParam.size >0"></if>

4. Determine whether the String starts with a specific character (such as "user" here)

<if test="stringParam.indexOf('user') != -1"></if>

5. Determine whether the string is equal to a specific character (such as user here)

<if test='stringParam != null and stringParam == "user"'></if>

Note You can not use this wording <if test="stringParam != null and stringParam != 'user'"></if>that is outermost in double quotes inside single quotes, this wording will hold java.lang.NumberFormatException anomaly
if you want to use this wording <if test="stringParam != null and stringParam != 'user'.toString()"></if>

Guess you like

Origin blog.csdn.net/ampsycho/article/details/105680295