直接上代码,关键需要进行2个判定,一个是null判定,一个是 ‘’ 判定。 <where> <if test="url!= null and url!=''"> url LIKE #{url} </if> </where>