码迷,mamicode.com
首页 > 其他好文 > 详细

查询中mybatis的if判断里传入0

时间:2018-08-06 14:42:00      阅读:143      评论:0      收藏:0      [点我收藏+]

标签:类型   没有   col   mybatis   tis   去掉   判断   自动   and   

1.传入的是long 或者 Integer类型 ,<if test="id != null ">

 

但是id传值为0时(前提是id对应的类型为long 或者 Integer,String型无此问题),发现并没有执行if里的sql,因为在mybatis中会自动把0当成null,所以if判断为false,如果要传值为0时判断为true,只要将判断为空串的判断去掉即可

 

2.传入string类型,   <if test="id !=null and id !=‘‘">

查询中mybatis的if判断里传入0

标签:类型   没有   col   mybatis   tis   去掉   判断   自动   and   

原文地址:https://www.cnblogs.com/ynhk/p/9429896.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!