mybatis的if判断integer问题
作者:程序猿001 时间:2022-12-23 20:15:41
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的参数等于‘’空串。
以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。
来源:https://www.cnblogs.com/zhaoyan001/p/10515405.html
标签:mybatis,if判断,integer
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Android超实用的Toast提示框优化分享
2022-12-20 08:36:32
c# 获取字符串的字节数的方法
2022-01-17 13:52:50
Android编程实现简单文件浏览器功能
2022-01-02 06:13:46
![](https://img.aspxhome.com/file/2023/8/99798_0s.jpg)
Android中通过MediaStore获取音乐文件信息方法
2021-09-30 17:53:24
详解Mybatis注解写法(附10余个常用例子)
2023-01-19 03:39:53
![](https://img.aspxhome.com/file/2023/7/113187_0s.jpg)
c#基数排序Radix sort的实现方法
2021-07-25 02:02:21
解读@RequestBody与post请求的关系
2022-10-07 02:02:51
![](https://img.aspxhome.com/file/2023/7/95037_0s.png)
提示信息控件AlertDialog对话框详解
2022-04-18 22:20:45
剖析Java中线程编程的概念
2022-02-02 04:12:51
![](https://img.aspxhome.com/file/2023/7/77967_0s.jpg)
Java调用Shell命令的方法
2022-01-06 20:01:34
WinForm实现鼠标拖动控件跟随效果
2021-12-16 01:31:23
![](https://img.aspxhome.com/file/2023/9/111279_0s.png)
Android入门简单实例
2021-07-26 16:34:04
![](https://img.aspxhome.com/file/2023/1/75411_0s.jpg)
SpringBoot+Dubbo+Zookeeper实现简单分布式开发的应用详解
2022-03-02 00:47:40
![](https://img.aspxhome.com/file/2023/8/83158_0s.png)
Effective Java (异常处理)
2022-09-24 12:17:29
SpringCloud读取Nacos配置中心报错及遇到的坑:Could not resolve placeholder ‘xxx’ in value ‘${xxx}
2022-12-26 04:41:02
![](https://img.aspxhome.com/file/2023/5/129225_0s.png)
c#实现KTV点歌系统
2023-10-17 23:54:56
![](https://img.aspxhome.com/file/2023/9/100199_0s.png)
springboot整合kaptcha生成验证码功能
2023-07-14 21:48:51
![](https://img.aspxhome.com/file/2023/6/71896_0s.png)
java pdf加水印的方法
2022-09-03 06:06:50
实例讲解Java中动态代理和反射机制
2022-06-29 04:00:50
Spring容器-BeanFactory和ApplicationContext使用详解
2022-03-20 07:02:45