Mybatis中#和$的区别
来源:互联网 发布:淘宝链接转淘客链接 编辑:程序博客网 时间:2024/06/05 15:14
1 #是将传入的值当做字符串的形式,eg:select id,name,age from student where id =#{id},
当前端把id值1,传入到后台的时候,就相当于 select id,name,age from student where id ='1'.
2 $是将传入的数据直接显示生成sql语句,eg:select id,name,age from student where id =${id},
当前端把id值1,传入到后台的时候,就相当于 select id,name,age from student where id = 1.
3 使用#可以很大程度上防止sql注入。(语句的拼接)
4 传入一个不改变的字符串或者传入数据库字段(列名),例如要传入order by 后边的参数,这种情况下必须使用${}
5 模糊查询中,如果使用如下方式:select * from reason_detail where reason_en like '%${reason}%',此处只能使用$,使用#的话,反而会被解析为列,报错java.sql.SQLException: Column 'reason' not found
阅读全文
0 0
- mybatis中#和$的区别
- mybatis中#和¥的区别
- Mybatis中#和$的区别
- Mybatis中#和$的区别
- mybatis中$和#的区别
- MyBatis中$和#的区别
- MyBatis中$和#的区别
- MyBatis中#和$的区别
- mybatis中#{}和${}的区别
- Mybatis中#和$的区别
- MyBatis中#{}和${}的区别
- Mybatis中#和$的区别
- MyBatis中#和$的区别
- mybatis中#和$的区别
- MyBatis中#{}和${}的区别
- mybatis中${}和#{}的区别?
- mybatis中#和$的区别
- mybatis中"#"和"$"的区别
- Java语法基础练习题1 2017/9/14
- java 反射 joor
- CODE[VS]1023 GPA计算
- Android中JSONObject与JsonObject的区别
- 搜索框提示相关内容
- Mybatis中#和$的区别
- android 浅尝JNI 打包so库
- Android中解决由单例引起的内存泄漏问题
- 遍历目录及子层目录下的所有文件
- 安卓5.1屏蔽recent_apps
- 应用程序无法正常启动(0xc000007b)。请单击确定关闭应用程序
- java基础2
- [err]1292
- eclipse 活动页签 tab页签 乱码