错误原因:在mybatis xml文件中的动态sql,if test 非空判断类型出错,把JSONArray与空串作比较,代码片段如下:
**错误原因:**在mybatis xml文件中的动态sql,if test 非空判断类型出错,把JSONArray与空串作比较,代码片段如下:
<if test="list != null and list !=''">
and bp.id in
<foreach collection="list" item="item" index="index" open="("
separator="," close=")">
#{item}
</foreach>
</if>
其中 items 为JSONArray,所以上面代码片段出错位置是 【items !=’’ '】
即去掉 【and items != ‘’】
本文解析了在MyBatis XML文件中使用动态SQL时常见的错误,具体讨论了if test条件判断中将JSONArray与空字符串进行比较的问题,并提供了正确的代码示例。

206

被折叠的 条评论
为什么被折叠?



