The limit dynamic parameter of Ibatis in MySQL

Source: Internet
Author: User

Param.put ("PageNo", PageNo);
Param.put ("PageSize", pageSize);

Usage in the Sqlmap
Limit ${pageno},${pagesize}
I hit the code today with the result of the error: Limit #pageNo #, #pageSize #
And then we found out about the data.
The limit should not be followed by # (I pass in an integer), but should be in $,
The difference between #与 $. (usually you can use the #, do not use $.)
#是把传入的数据当作字符串, such as #pageno# incoming is pageno, then SQL statement generation is so, limit ' pageno ', will error.
The incoming data is generated directly in SQL, such as #pageno# incoming pageno, then SQL statement generation is so,
Limit PageNo value, pagesize value
#方式能够很大程度防止sql注入. The $ method cannot prevent SQL injection.
The $ method is typically used to pass in database objects. For example, incoming table names.

The limit dynamic parameter of Ibatis in MySQL

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.