Mybatis3.1.1 if 或者 when判断条件不通过的问题

来源:互联网 发布:网络英语统考 编辑:程序博客网 时间:2024/05/16 01:43
调查了很久,终于找到了问题之所在。
Mybatis3.1.1中 if 或者 when如果按照下面的写法是不会通过的。

错误写法:
<when test="reqType != null and reqType == '0'">
<if test="reqType != null and reqType == '0'">
因为里面的单引号包裹的字符串(例子中是'0')解析时候被去掉单引号认为是数值。

正确写法:
<when test="reqType != null and reqType == '0'.toString()">
<if test="reqType != null and reqType == '0'.toString()">
或者
<when test='reqType != null and reqType == "0"'>
<if test='reqType != null and reqType == "0"'>

多么痛的领悟!
4 0
原创粉丝点击