在mybatis中使用choose中,when test后面写了类似下面的代码
<choose>
<when test="obj.col != null and obj.col == 'xxx'">
case 1
</when>
<when test="obj.col != null and obj.col == 'xxxxx'">
case 2
</when>
...
</choose>
发现不管传入的参数如何,日志打印的sql出来都只走都了case 1 ,经过搜索得知,得把test后面最外层用单引号,里面字符串得部分用双引号
<when test='obj.col != null and obj.col == "xxxxx"'>
case
</when>
或者
<when test="obj.col != null and obj.col == 'xxxxx'.toString()">
case
</when>