Mybatis傳入參數0 ,會成為空


從頁面傳參數 is_send= 0 到mapper.xml

傳入的這個參數類型如果不是字符串類型的話

在xml 經過if(test="is_send!=null and is_send !=''") 這樣判斷的話,那么這個0就會是空

if(test="is_send!=null ) 如果去掉and is_send !=''" 這個,那么就會識別成為0

<result column="is_sent" property="isSent" jdbcType="INTEGER" />

 

以下正確,如果傳0進來會識別成為0:

<if test="data.isSent != null "> 

    and is_sent=#{data.isSent,jdbcType=INTEGER}  

   </if> 

以下錯誤,如果傳0,就不會進if條件:

<if test="data.isSent != null and data.isSent!='' "> 

   and is_sent=#{data.isSent,jdbcType=INTEGER}  

  </if>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM