mybatis: 標簽使用小細節


if標簽里,test可以比較字符串,int,null等。

其中:

1:空字符串比較

<if test="a ==/!= '' ">

</if>

2:null比較

<if test="a ==/!= null ">

</if>

 

3:數字比較

<if test="a == 1">

</if>

 

4:字符串比較

<if test="a == '1'.toString() ">

</if>

或者

<if test='a == "1" '>

</if>

如果test是雙引號,里面的字符串用單引號並加.toString()
如果test是單引號,里面的字符串用雙引號就行

5:test里面還可以加and,or,()等

<if test="a == 1 or (b == 2 and c == 3) or d == 4 ">

</if>


免責聲明!

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



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