一般我们判断不等于用!=没有问题:
<if test="type !=null and type !=' ' ">
AND COST_PRO_TIMESHEET_ID <> #{costProTimesheetId}
</if>
但如果判断等于是不是用==就可以了?其实不是:
这样无法进入判断;应该使用以下两种写法:
<if test="type ==‘A’ .toString()"> //加上.toString()
<if test='type =="A" '> //单引号在外面
原因:因为因为mybatis会把’A’解析为字符,java是强类型语言,所以不能这样写。