mybatis 中模糊查询的两种形式

版权声明: https://blog.csdn.net/qq_32157851/article/details/89082421

方法一: 

select *
		from tbl_web where 1=1 and delete_flag = 0 
		<if test="Url !=null and Url !=''">and url like '%'|| #{Url} ||'%' </if>

 方法二:

​
select *
		from tbl_web where 1=1 and delete_flag = 0 
		<if test="Url !=null and Url !=''">and url like '%${Url}%' </if>

​

注:方法一可以有效的防止sql注入

猜你喜欢

转载自blog.csdn.net/qq_32157851/article/details/89082421