Mybatis中#{}和${}传参的区别

使用#{}传入参数时,sql语句解析是会加上''。#方式能够很大程度防止sql注入。

${}将传入的数据直接显示生成在sql中。

例如:select * from user_role where user_code = ‘100’;

这句话而言,需要写成 select * from ${tableName} where user_code = #{userCode}

原文地址:https://www.cnblogs.com/shizilunya/p/8444383.html