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的语法不允许吧)

Logo

基于 Vue 的企业级 UI 组件库和中后台系统解决方案,为数万开发者服务。

更多推荐