首页 > 其他 > 详细

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

时间:2015-06-17 13:29:16      阅读:464      评论:0      收藏:0      [点我收藏+]
调查了很久,终于找到了问题之所在。
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"‘>

多么痛的领悟!

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

原文:http://blog.csdn.net/dongganxingkong/article/details/46532067

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!