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