您的位置:宽带测速网 > 网络知识 > 模糊查询如何解决sql语句注入问题

模糊查询如何解决sql语句注入问题

2025-06-17 10:10来源:互联网 [ ]

模糊查询解决sql语句注入问题的示例:

使用mysql中concat函数可以解决sql注入又能够在位置文件中写%,代码如下:

<selectid="selectByName"resultType="cn.test.domain.Employee">

select

id,emp_nameasempName,

sex,email,birthday,address

from

t_employee

where

emp_namelikeconcat(‘%‘,#{empName},‘%‘)

</select>