mybatis 參數爲Integer型數據並賦值0時,0被當作空處理:html
mybatis.xml中有if判斷條件判斷參數不爲空時,賦值爲0的Integer參數被mybatis判斷爲空, 不執行<if test="param != null and param != ''"></if>的sql。sql
解決方法: 判斷非空改成:<if test="param != null"</if>apache
用到mybatis時,避免用0來作值mybatis
官方解釋: https://commons.apache.org/proper/commons-ognl/language-guide.htmlide
Interpreting Objects as Booleans Any object can be used where a boolean is required. OGNL interprets objects as booleans like this: If the object is a Boolean, its value is extracted and returned; If the object is a Number, its double-precision floating-point value is compared with zero; non-zero is treated as true, zero as false; If the object is a Character, its boolean value is true if and only if its char value is non-zero; Otherwise, its boolean value is true if and only if it is non-null.ui