mybatis中为了防止sql注入,使用like语句时并不是直接使用,而是使用concat函数
<if test="goodName != null and goodName != ''"> and good_name like concat('%', #{goodName}, '%')</if>
concat()函数
1、功能:将多个字符串连接成成一个字符串。
2、语法:concat(str1, str2,…)
说明:返回结果为连接参数产生的字符串,如果有任何一个参数为null,则返回值为null。