1.判断String是否为空
<if test="stringParam != null and stringParam != ''"></if>
2.判断Integer是否大于0
<if test="idParam !=null and idParam gt 0"></if>
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>
MyBatis中mapper.xml配置文件中的各种判断
猜你喜欢
转载自chenleilei-92.iteye.com/blog/2393008
今日推荐
周排行