mybatis 中 if 标签判断字符串相等

直接判断不生效 如:

<if test="sort == '1'">
       score desc,
</if>

mybatis 映射文件中,if标签判断字符串相等,两种方式:因为mybatis映射文件,是使用的ognl表达式,所以在判断字符串sex变量是否是字符串Y的时候使用 如:

<test="sex=='Y'.toString()"> 或者 <test = 'sex== "Y"'>

(参考:https://blog.csdn.net/chengsi101/article/details/78804224)

修改以上代码 

<if test="sort == '1'.toString()">
       score desc,
</if>
原文地址:https://www.cnblogs.com/zagwk/p/15351432.html