mybatis if判断字符串
正确写法:
<if test="userCode != null and userCode !=''
and userCode !='admin'.toString()">
或者
<if test='userCode != null and userCode !=""
and userCode !="admin" '>
错误写法:
<if test="userCode != null and userCode !="" and userCode !='admin' ">
mybatis是使用的OGNL表达式来进行解析的,在OGNL的表达式中,"admin"会被解析成字符串,
因为java是强类型的,char 和 一个String 会导致不等。所以if标签中的sql不会被解析。