代碼如下:
<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在反射的時候會加上方法
執行結果: