问题
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
回答1:
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 ) } )
来源:https://stackoverflow.com/questions/24782233/passing-two-values-for-one-parameter-inside-remotefunction