mybatis 关于 if test 判断字符串的大坑

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

  1.  
<if test="sex=='Y'.toString()">
  1.  
<if test = 'sex== "Y"'>

注意:
不能使用

<if test="sex=='Y'">
and 1=1
</if>
posted @ 2019-05-20 09:34  海尚书  阅读(1097)  评论(0)    收藏  举报