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>

posted @ 2020-12-08 18:25  路要一步一步走  阅读(5273)  评论(0编辑  收藏  举报