使用PageHelper分页插件后,用
SELECT * FROM score
ORDER BY score desc
limit 2
就会报错,显示
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Fri Aug 02 09:42:10 CST 2019
There was an unexpected error (type=Internal Server Error, status=500).
### Error querying database. Cause: java.sql.SQLSyntaxErrorException: 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 'LIMIT 5' at line 3 ### The error may exist in file [F:\PE\exercise_01\target\classes\mapper\ScoreMapper.xml] ### The error may involve defaultParameterMap ### The error occurred while setting parameters ### SQL: SELECT * FROM score ORDER BY score desc limit 2 LIMIT ? ### Cause: java.sql.SQLSyntaxErrorException: 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 'LIMIT 5' at line 3 ; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: 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 'LIMIT 5' at line 3
可以用PageHelper.clearPage();作用是手动清理 ThreadLocal 存储的分页参
后面再用就不会有错