使用#{}传入参数时,sql语句解析是会加上''。#方式能够很大程度防止sql注入。
${}将传入的数据直接显示生成在sql中。
例如:select * from user_role where user_code = ‘100’;
这句话而言,需要写成 select * from ${tableName} where user_code = #{userCode}
使用#{}传入参数时,sql语句解析是会加上''。#方式能够很大程度防止sql注入。
${}将传入的数据直接显示生成在sql中。
例如:select * from user_role where user_code = ‘100’;
这句话而言,需要写成 select * from ${tableName} where user_code = #{userCode}