jfinal的paginate方法可以带参数吗?

波总您好,各位同行大家好!

最近使用jfinal的时候遇到个问题,paginate会遇到下面的报错信息(图1),图片不清楚怎么换行请看下面第一张图片的sqlException报错的原因一般是符号的问题,于是我去找了url的传值(图2),可能是传值问题,还有设置的参数(图3),以及在sql语句中的错误(图4),谢谢大家

图1

4.png

图2

3.png


图3

1.png


图4


2.png








评论区

JFinal

2019-01-19 11:58

最外层的 select 子句不要包含参数

解决办法是最外套一层select :
select * from ( 原 sql ) as temp

这里有详细的说明:
https://www.jfinal.com/doc/5-6

kings186

2019-01-19 14:11

@JFinal
波总您好,谢谢您的回答,上面已经改了sql语句,但是还是会报下面的错误

sql语句是这样的:
select *
FROM
(select *,
(select count(1) from organize_course oc where o.uid =oc.organize_uid) AS course_num,
(SELECT count(1) FROM organize_course oc WHERE o.uid =oc.organize_uid AND oc.status=1)as onsale_num,
(SELECT COUNT(1) FROM organize_member om WHERE o.uid =om.organize_uid AND member_role =2) AS stu_num,
(SELECT COUNT(1) FROM social_like sc WHERE o.uid =sc.target_uid ) AS fans_num
from organize o
ORDER BY #para(orderType) #para(orderMode)) as temp

下面的是报错信息:

com.jfinal.core.ActionHandler.error /organize/listOrganize?page=1&order_type=course_num&order_mode=DESC
com.jfinal.plugin.activerecord.ActiveRecordException: java.sql.SQLException: sql injection violation, syntax error: syntax error, error in :'nize o
?) as temp
',expect RPAREN, actual QUES o : select count(*) from
(select *,
(select count(1) from organize_course oc where o.uid =oc.organize_uid) AS course_num,
(SELECT count(1) FROM organize_course oc WHERE o.uid =oc.organize_uid AND oc.status=1)as onsale_num,
(SELECT COUNT(1) FROM organize_member om WHERE o.uid =om.organize_uid AND member_role =2) AS stu_num,
(SELECT COUNT(1) FROM social_like sc WHERE o.uid =sc.target_uid ) AS fans_num
from organize o
?) as temp

JFinal

2019-01-19 19:01

异常提示已经很清楚,语法错误,缺少右括号

要输就输给追求

2019-01-21 11:42

order by 后面不要用 #para() 直接 #() 就可以了

kings186

2019-01-21 14:16

@JFinal 好的,谢谢波总

kings186

2019-01-21 14:16

热门反馈

扫码入社