mybatis字符串匹配数字

来源:互联网 发布:前10月经济数据 编辑:程序博客网 时间:2024/05/29 08:04

做查询遇到一个坑,想用字符串去判断是否等于一个数字,结果一个报错,写法如下

<if test="taskIdType != null and taskIdType != '0' ">     and task_id like CONCAT(CONCAT('TASK', #{taskIdType}), '%')</if>

正确写法如下

<if test="taskIdType != null and taskIdType != '0'.toString() ">     and task_id like CONCAT(CONCAT('TASK', #{taskIdType}), '%')</if>

<if test='taskIdType != null and taskIdType != "0" '>    and task_id like CONCAT(CONCAT('TASK', #{taskIdType}), '%')</if>