mybatis 中if标签判断boolean 的写法。

mybatis 的if 比较标签在比较数值时可以这样写:

<if test="value=0">

</if>

在比较字符串时可以这么写:

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

</if>

记得是外面是单引号,里面是双引号。

同时,字符串参数要设置getter 方法(我这里使用注解设置)。

那么在比较布尔值时呢?

我凭我个人经验这边总结出两种方法:

1、

<if test="boolvalue">

//boolvalue=true 时

</if>

2、

<if test="boolvalue==true">

//boolvalue=true 时

</if>

 博主开源项目:https://github.com/Enast/hummer,走过路过,请点个赞

原文地址:https://www.cnblogs.com/HendSame-JMZ/p/6041543.html