MyBatis @Insert
import org.apache.ibatis.annotations.Insert;
select * from user where name = # {name};会被解析为:select * from user where name = ?;
select * from user where name = $ {name};sql会解析为:select * from user where name = “sprite”;
$ { } 的变量的替换阶段是在动态 SQL 解析阶段,而 # { }的变量的替换是在 DBMS 中。# {}将传入的参数当成一个字符串,会给传入的参数加一个双引号$ {}将传入的参数直接显示生成在sql中,不会添加引号。# {}防止sql注入,$ {}无法防止sql注入。
参考:
https://blog.csdn.net/weixin_39980711/article/details/113417644