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在反射的时候会加上方法

执行结果:

原文地址:https://www.cnblogs.com/blogspring/p/10123265.html