在查询条件中,如果查询字段为integer,并且值为0,在xml查询语句<if test=“参数 != null and 参数 != ‘‘“>这时候是不会进去的。
原因:
mapper接口传入的参数类型为Integer值为0时,会默认将这个值转换为空字符串!
解决办法:
1、去掉【参数 != ‘‘“】的非空判断,因为Integer类型的值除了0也不可能为空字符串
2、不用integer类型,直接换成string类型
在查询条件中,如果查询字段为integer,并且值为0,在xml查询语句<if test=“参数 != null and 参数 != ‘‘“>这时候是不会进去的。
原因:
mapper接口传入的参数类型为Integer值为0时,会默认将这个值转换为空字符串!
解决办法:
1、去掉【参数 != ‘‘“】的非空判断,因为Integer类型的值除了0也不可能为空字符串
2、不用integer类型,直接换成string类型