mybatis的映射xml文件中使用if标签判断字符串相等时需要注意使用ognl表达式,如下所示 可用的两种写法如下: 写法一: <if test="flag=='Y'.toString()"> and 1=1 </if> 写法二: <if test = 'flag== "Y"'> and 1=1 </if> 不可用写法如下,注意会错: <if test="flag=='Y'"> and 1=1 </if>