1. 程式人生 > >mybatis中的limit引數

mybatis中的limit引數

引數page=1,rows=3

錯誤寫法:select   *   from  xxx  limit  #{page},#{rows}

報錯:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''1','3'' at line 1

可以看出mybatis自動給我們的引數加了 引號 ' ',所以報錯

解決方法:#{}改為${}

正確寫法:select   *   from  xxx  limit  

${page},${rows}