<if test="characteristicName != null and characteristicName !=''">
AND CHARACTERISTIC_NAME=#{characteristicName}
</if>
<if test="characteristicName == null">
AND CHARACTERISTIC_NAME is null
</if>
需要注意的是
① 如果 characteristicName 字段值为junk ,mybaties会把sql语句转换成"select * from table where receivedName="junk".
② 如果 characteristicName 字段值为 "",则以上俩个条件都不能满足,所以转化后的sql语句是"select * from table where 1=1".