方法一:concat
<where>
<trim suffixOverrides="," >
<if test="id != null and id != ''" >
and id = #{id}
</if>
<if test="name != null and name != ''" >
and name like concat('%',#{name},'%')
</if>
</trim>
</where>
方式二:${}
<if test="examTypeName!=null and examTypeName!=''">
and exam_type_name like '%${examTypeName}%'
</if>
方式三:#{}
<if test="examTypeName!=null and examTypeName!=''">
and exam_type_name like "%"#{examTypeName}"%"
</if>
注意
模糊查询:’%${value}%’ 不可漏掉单引号,不能添加jadbType
参考文章