zoukankan      html  css  js  c++  java
  • org.springframework.dao.TransientDataAccessResourceException

    今天给大家分析一个在mybatis中遇见的错误

    是什么原因导致这个错误信息呢,请看下面代码

    再来看看下面找个

    发现区别在哪里没有,没错就是#与$的区别。

    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 在大多数情况下还是经常使用#,但在不同情况下必须使用$. 

    如有需要可以加我Q群【308742428】大家一起讨论技术。

    后面会不定时为大家更新文章,敬请期待。

    喜欢的朋友可以关注下。

  • 相关阅读:
    hdu 3074 Multiply game
    uva 10717 Mint
    uva 10128 Queue
    uva 10673 Play with Floor and Ceil
    hdu 1754 I Hate It
    hdu 1166 敌兵布阵
    uva 10079 Pizza Cutting
    费波那列素数
    uva 10236 The Fibonacci Primes
    hdu 1698 Just a Hook
  • 原文地址:https://www.cnblogs.com/dsn727455218/p/10245519.html
Copyright © 2011-2022 走看看