Mybatis mapper.xml 判断条件写法注意
2017-12-01 15:08
1311 查看
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>
转载Mark
相关文章推荐
- mybatis的mapper.xml用条件判断做转译
- MyBatis中Mapper.xml文件中关于字符串的判断写法(已经验证好用)
- Mybatis动态sql条件查询中if判断Integer的条件写法
- 列表上移下移的SQL语句(mybatis mapper.xml写法)
- mybatis mapper.xml 区间查询条件
- mybatis 模糊查询 mapper.xml的写法
- MyBatis Mapper.xml各种判断
- mybatis的mapper.xml利用map遍历集合进行插入,以及利用list进行遍历插入的注意点
- mybatis映射文件mapper.xml的写法。
- mybatis 传参为 Integer 时 ,Mapper 文件 中判断 条件 问题,传入0值,直接忽略判断
- mybatis中mapper进行if条件判断
- mybatis写mapper xml文件注意事项
- MyBatis Mapper.xml各种判断
- Mybatis中mapper.xml文件判断语句中的单双引号问题
- mybatis中mapper.xml中模糊查询写法
- 使用mybatis时Mapper.xml文件中如何判断多个参数不为空和null
- mybatis的mapper配置文件配置oracle的判断是否成年的sql简洁写法。
- mybatis 关联对象mapper.xml的写法
- Mybatis Mapper.xml继承机制
- ABAP-判断内表是否为空注意写法