关于mybatis传入0被判断为空的问题

<if test="status!= null  and status!= ''">
  status=#{status},
</if>

在mybatis中这样写的话,若是是String类型的话是没有任何问题的,可是若是是传入的Integer的话就会出现传入0被判断为空的现象,可是也不是必现的,为何不是必现的也不太清,可是若是变量的值是0,即 status= 0, mybatis在进行 status!= ‘’ 的时候会认为 status的值是空字符串, 即 status== ‘’ 为true。因此若是是Integer类型只须要判断 != null 便可mybatis

相关文章
相关标签/搜索