执行let page = body.pageNum; let size = body.pageSize; let sql = """ select * from grid_table where (name like '%${body.name}%' or comment like '%${body.comment}%' or addtime = #{body.addtime} ) -- <if test="body.search != null and body.search!=''"> and (name like '%${body.name}%' or comment like '%${body.comment}%' or addtime = #{body.addtime} )</if> """; db.use("fast_admin").getSql(sql) return kits.toZx(db.use("fast_admin").page(sql));报错:"系统内部出现错误|PreparedStatementCallback; bad SQL grammar [select count(1) from (select * from grid_table where (name like '%goku_page%' or comment like '%111%' or addtime = ? )\n --) count_]; 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 ') count_' at line 2 at Row:9~9,Col:39~47\n\nreturn kits.toZx(db.use(\"fast_admin\").page(sql));\n ^^^^^^^^^ ",
时间: 2024-03-27 22:40:38 浏览: 44
simple_page.rar_page_struts 分页
根据错误信息,看起来是您的SQL语句缺少必要的结尾语句,导致查询出错。您可以尝试在SQL语句的最后加上";",如下所示:
```
let page = body.pageNum;
let size = body.pageSize;
let sql = """
select * from grid_table
where (name like '%${body.name}%' or comment like '%${body.comment}%' or addtime = #{body.addtime} )
-- <if test="body.search != null and body.search!=''">
and (name like '%${body.name}%' or comment like '%${body.comment}%' or addtime = #{body.addtime} )
</if>
""";
sql = sql + ";"; // 加上分号
db.use("fast_admin").getSql(sql);
return kits.toZx(db.use("fast_admin").page(sql));
```
另外,您也需要检查SQL语句中的占位符是否正确,确保它们与查询参数匹配。
阅读全文