当前位置: 代码迷 >> 综合 >> mybatis 3种模糊查询
  详细解决方案

mybatis 3种模糊查询

热度:27   发布时间:2023-10-17 19:38:34.0
前三种模糊查询
#{参数名称}可以防注入,推荐使用
${参数名称},容易被注入,不推荐使用,
<select id="getUserList" resultMap="user">SELECT id,username,nickname,phone,email FROM sys_userWHERE del_flag = 0<if test="username!=null and username !=''">and username = "%"#{username}"%" </if><if test="nickname!=null and nickname !=''">and nickname like concat(concat(#{nickname},'%'),'%')</if><if test="phone!=null and phone !=''">and phone like '%${phone}%'</if>
</select>

 

  相关解决方案