mybatis test 比較字符串老是無效


代碼如下:

<when test="customerType == '0'">
    <include refid="Reception"/>
</when>
<otherwise>
    <include refid="NotReception"/>
</otherwise>

變量:          customerType  是String  類型的     

test="customerType == '0' "     這樣判斷的話   會發現執行到 引用   NotReception   中去  !

執行結果:

 

解決方法:

<when test='customerType == "0"'>    用 單引號包住最外層 里面使用 雙引號引用是可以的  不過更好的辦法是
<when test="customerType == '0'.toString()">  在引用字符串參數后 加上 toString() 方法,mybatis在反射的時候會加上方法

執行結果:


免責聲明!

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



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