mybatis的 条件判断
在使用 MyBatis if 进行条件判断时,一直报错:
<if test="fwbdh != null and fwbdh == BAK">
fwbdh=#{fwbdh}
<if>
MyBatis是使用的OGNL表达式来进行解析的,改成:
<if test=fwbdh != null and fwbdh == "BAK">
fwbdh=#{fwbdh}
<if> 同时,MyBatis的if、when里面的test表达式对参数进行判断时,可以调用
java的java.lang.String中定义的方法:
比如:
<if test="fwbdh != null and fwbdh != ">
<choose>
<when test=fwbdh.indexOf(",") != -1>
AND t.FWBDH in (${fwbdh})
</when>
<otherwise>
AND t.FWBDH like %+#{fwbdh}+%
</otherwise>
</choose>
</if>
在使用 MyBatis if 进行条件判断时,一直报错:
-
顶
- 0
-
踩
