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

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

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

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

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

posted @ 2018-02-12 13:53  Ananco  阅读(202)  评论(0编辑  收藏  举报