<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 傳入後會變成 ‘’,誰知道...求告知...