好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

mybatis的if判断integer问题

if判断integer的问题

昨天在使用mybatis的if判断integer时遇见一个小问题:

?

1

2

3

< if test = "isChoose != null and isChoose != '' and isChoose == 0" >

    

</ if >

我发现前段同事调用接口的时候传参总是无法进入条件,

原来mybatis的if将0认为是'',所以这样判断是无法进入条件的,将数字换为1,2之类的就可以了;

if判断integer类型注意点

今天在写mapper文件时遇到integer类型参数时判断不为空,如下

?

1

2

3

< if test = "status != null and status != ''" >

    SQL。。。

</ if >

当status=0时,if语句没有执行。

究其原因,原来mybatis默认将integer=0的参数等于‘’空串。 

以上为个人经验,希望能给大家一个参考,也希望大家多多支持。 

原文链接:https://HdhCmsTestcnblogs测试数据/zhaoyan001/p/10515405.html

查看更多关于mybatis的if判断integer问题的详细内容...

  阅读:17次