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"'>
错误写法:
<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"'>
转自:https://blog.youkuaiyun.com/dongganxingkong/article/details/46532067