传递两个值内RemoteFunction一个参数 [英] Passing two values for one parameter inside RemoteFunction
本文介绍了传递两个值内RemoteFunction一个参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
GSP
< G:从=选择[附属机构,自定义搜索引擎,DISPLAYADS,电子邮件,MOBILEWEB,他人,有机,搜索引擎优化,SEM]NAME =MVID =MV
的onchange =$ {remoteFunction(
控制器:Pgtyp,
动作:ajaxGetMv,
params:一个'\'MV = \'+逃生(THIS.VALUE)+ \'和; date_hour = \'+ Z + \'和; date_hour = \'+ B',
//params:'\'mv=\'+this.value',
的onSuccess:'printpgtyp(数据))}
>< / G:选择>
控制器
高清pgtyp = Pgtyp.executeQuery(选择p.date_hour,p.visits,p.mv,p.browser,p.pagetype,p.platform,p.device,P从Pgtyp p .time_period,其中p.mv =和p.date_hour>?=和p.date_hour< =为了通过col_0_0_ ASC,[params.mv,params.date_hour,params.date_hour])
这是我试过的一个参数传递两个值。我究竟做错了什么?我如何使它工作?
UPDATE1
这是我得到的错误:
错误:预期位置参数个数:3,实际参数:[SEO,[Ljava.lang.String; @ 6e5980,[Ljava.lang.String; @ 6e5980] [从Pgtyp p选择p.date_hour,p.visits,p.mv,p.browser,p.pagetype,p.platform,p.device,p.time_period哪里p.mv =?和p.date_hour> =?和p.date_hour< =?为了通过col_0_0_递增。堆栈跟踪如下:
消息:预计位置参数个数:3,实际参数:[SEO,[Ljava.lang.String; @ 6e5980,[Ljava.lang.String; @ 6e5980] [选择p.date_hour,p.visits,p.mv ,p.browser,p.pagetype,p.platform,p.device,p.time_period从Pgtyp p其中p.mv =?和p.date_hour> =?和p.date_hour< =?为了通过col_0_0_升序]
线|方法
- >> 13 | doCall在marchmock2.PgtypController $ _closure1 $$ EOkBYvqz
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 200 |的doFilter在grails.plugin.cache.web.filter.PageFragmentCachingFilter
| 63 |的doFilter在grails.plugin.cache.web.filter.AbstractFilter
| 1145 | runWorker在java.util.concurrent.ThreadPoolExecutor中
| 615 |跑 。 。 。在java.util.concurrent.ThreadPoolExecutor中的$工作者
^ 744 |在java.lang.Thread中运行
解决方案
您需要使用 params.list()
方法在你的控制器:
高清pgtyp = Pgtyp.executeQuery(选择p.date_hour,p.visits,p.mv,p.browser,p.pagetype,p.platform,p.device,P从Pgtyp p .time_period,其中p.mv =和p.date_hour>?=和p.date_hour< =为了通过col_0_0_ ASC,[params.mv] + params.list('date_hour').collect { dateFormatter.parse(它)})
GSP
<g:select from="['AFFILIATES', 'CSE','DISPLAYADS','EMAIL','MOBILEWEB','OTHERS','ORGANIC','SEO', 'SEM']" name="mv" id = "mv"
onchange="${remoteFunction(
controller:'Pgtyp',
action:'ajaxGetMv',
params:'\'mv=\' + escape(this.value)+\'&date_hour=\'+z+\'&date_hour=\'+ b',
//params:'\'mv=\'+this.value',
onSuccess: 'printpgtyp(data)')}"
></g:select>
Controller
def pgtyp = Pgtyp.executeQuery("select p.date_hour ,p.visits, p.mv, p.browser,p.pagetype,p.platform,p.device,p.time_period from Pgtyp p where p.mv = ? and p.date_hour >= ? and p.date_hour <= ? order by col_0_0_ asc ",[params.mv, params.date_hour,params.date_hour])
This is what I tried for passing two values for one parameter. What am I doing wrong? How do i make it work?
UPDATE1
This is the error that I got:
ERROR:Expected positional parameter count: 3, actual parameters: [SEO, [[Ljava.lang.String;@6e5980, [Ljava.lang.String;@6e5980]] [select p.date_hour ,p.visits, p.mv, p.browser,p.pagetype,p.platform,p.device,p.time_period from Pgtyp p where p.mv = ? and p.date_hour >= ? and p.date_hour <= ? order by col_0_0_ asc ]. Stacktrace follows:
Message: Expected positional parameter count: 3, actual parameters: [SEO, [[Ljava.lang.String;@6e5980, [Ljava.lang.String;@6e5980]] [select p.date_hour ,p.visits, p.mv, p.browser,p.pagetype,p.platform,p.device,p.time_period from Pgtyp p where p.mv = ? and p.date_hour >= ? and p.date_hour <= ? order by col_0_0_ asc ]
Line | Method
->> 13 | doCall in marchmock2.PgtypController$_closure1$$EOkBYvqz
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 200 | doFilter in grails.plugin.cache.web.filter.PageFragmentCachingFilter
| 63 | doFilter in grails.plugin.cache.web.filter.AbstractFilter
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 744 | run in java.lang.Thread
解决方案
you need to use the params.list()
method in your controller:
def pgtyp = Pgtyp.executeQuery("select p.date_hour ,p.visits, p.mv, p.browser,p.pagetype,p.platform,p.device,p.time_period from Pgtyp p where p.mv = ? and p.date_hour >= ? and p.date_hour <= ? order by col_0_0_ asc ", [ params.mv ] + params.list( 'date_hour' ).collect{ dateFormatter.parse( it ) } )
这篇关于传递两个值内RemoteFunction一个参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文