软件编程
位置:首页>> 软件编程>> java编程>> mybatis的if判断integer问题

mybatis的if判断integer问题

作者:程序猿001  发布时间:2022-12-23 20:15:41 

标签:mybatis,if判断,integer

if判断integer的问题

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

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

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

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

if判断integer类型注意点

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

<if test="status != null and status != ''">
    SQL。。。
</if>

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

究其原因,原来mybatis默认将integer=0的参数等于&lsquo;&rsquo;空串。 

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

来源:https://www.cnblogs.com/zhaoyan001/p/10515405.html

0
投稿

猜你喜欢

手机版 软件编程 asp之家 www.aspxhome.com