mybatis integer 類型0傳值問題。

新手, 接觸mybatis 有幾個月了,剛開始遇到過
<if test="status!=null and status!=''">
and status = '${status}'
</if>
當我status 傳入參數爲0的時候(Integer status ),到if 條件時,就不執行,被識別成 ‘’ 了。
以前我的做法是把 
and status != '' 這句去掉。昨天又遇到這個問題了,然後就再去百度了一下,還可以這樣寫:
<if test="status!=null and status!='' or status == 0">
	and status = '${status}'
</if>

但是我現在還是不知道爲什麼 integer 類型的 0 傳入後會變成 ‘’,誰知道...求告知...



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章