为一个参数传递两个值

为一个参数传递两个值

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])

这就是我为一个参数传递两个值的尝试。我究竟做错了什么?我该如何运作?

UPDATE1

这是我得到的错误:
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

最佳答案

您需要在 Controller 中使用params.list()方法:

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 ) } )

09-11 17:37