Mybatis中 和 符合的區別

2021-09-03 10:15:50 字數 340 閱讀 3351

# 是將傳入的值當做字串的形式,ex:select id, name from student where id = #,當將值 111 傳入到後台時,相當於 select id, name, age from student where id = "1"。

$ 是將傳入的值直接顯示生成 sql 語句,ex:select id, name from student where id = $,當將值 id 值111 傳入到後台時,相當於 select id, name, age from student where id = 1。

使用 # 可以很大程度上防止 sql 注入。

在使用 order by 時應使用 $。

myBatis中 和 區別

1.將傳入的資料都當成乙個字串,會對自動傳入的資料加乙個雙引號。如 order by user id 如果傳入的值是111,那麼解析成sql時的值為order by 111 如果傳入的值是id,則解析成的sql為order by id 2.將傳入的資料直接顯示生成在sql中。如 order by u...

mybatis 中 和 區別

在使用mybatis 框架時 在xml的配置檔案中,通常是使用 來獲取數值的 如 select from t user inf where id 這時 如果你傳入的值為zhangsan 則會編譯成為 select from t user inf where id zhangsan mybatis 會...

Mybatis 中 和 區別

號與 區別 號表示引數,代表乙個字串。如 select a,b,c from table1 where id value 傳入引數後如 value 1 則可生成 select a,b,c from table1 where id 1 select a,b,c from table1 where ci...