mybatis sql注入注意事项

216 阅读1分钟

1 模糊查询写法

  • 这类写法直接报错,切记不可使用$拼接 Select * from news where title like ‘%#{title}%’

  • 正确写法 select * from news where tile like concat(‘%’,#{title}, ‘%’)

  • in 写法

id in
<foreach collection="ids" item="item" open="("separatosr="," close=")">
#{ids}
</foreach>