MyBatis Mapper.xml 判断字符串是否相等

518 阅读1分钟

字符串等于条件的两种写法

① 将双引号和单引号的位置互换

<if test=' testString != null and testString == "A" '>
   AND 表字段 = #{testString}
</if>

② 加上.toString()

<if test=" testString != null and testString == 'A'.toString() ">
  AND 表字段 = #{testString}
</if>