mybatis报错:Error evaluating expression ‘stu.id != null AND stu.id != ‘’’. Cause: org
mybatis的mapper文件中报了这么一个错
Error evaluating expression 'id != null AND id != '' '
这个SQL如下:
<select id="xxx" parameterType="yyy" resultType="zz">
select * from stu
<where>
<if test="id != null AND id != '' ">
and id = #{id}
</if>
<!-- ... -->
</where>
</select>
解决:if标签的test里面的表达式的and不能写成大写AND。(具体的原因本人没有详细探究过,估计是mybatis的语法不允许吧)
本文解决了一个在MyBatis mapper文件中遇到的问题,即if标签内的test属性使用大写AND作为逻辑运算符时导致的错误。通过调整为小写and,成功避免了该语法错误。
2009

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



