MyBatis 中if 标签 判断字符串不生效
阿里
阅读:927
2021-03-31 16:57:18
评论:0
今天遇到if 标签判断字符串不生效,导致查询结果错误:
异常sql 的mapper 文件:
<if test="isBound != null and isBound !='' and isBound == '1'">
and box_sid is not null
</if>
<if test="isBound != null and isBound !='' and isBound == '2'">
and box_sid is null
</if>
正确sql 的mapper 文件
<if test="isBound != null and isBound !='' and isBound == '1'.toString()">
and box_sid is not null
</if>
<if test="isBound != null and isBound !='' and isBound == '2'.toString()">
and box_sid is null
</if>
声明
1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。