1. 程式人生 > >MyBatis把傳過來的Integer型別的0當作空字串

MyBatis把傳過來的Integer型別的0當作空字串

傳遞Integer型別的值,如果傳遞的是0,到mybatis的mapper的xml檔案中是把值當作空字串,mybatis原始碼對其進行了強制定義。

<if test="status != null and status !=  '' or status == 0">

使用時增加多一個or status == 0判斷

實際上,Integer型別和空字串是不需要判斷比較的。業務上一般比較是否為null就行了

<if test="status != null">