我有域“国家”,并在list.gsp我有搜索块与输入字段。 第一个问题是,当我试图在列表中使用paginate时,总是显示所有结果,在这种情况下,我提供了解决方案,并且只发送了10个值(如果您知道另一个解决方案,请告诉我)。我的搜索中查找此:grails分页的搜索结果
def search = {
if(query){
def srchResults = searchableService.search(query, params)
def result = Country.executeQuery("select new map(a.name as name, a.datacenter as datacenter) from Country a where a.name like '%"+ params.q + "%'")
if (params.offset)
{
x = params.offset.toInteger()
y = Math.min(params.offset.toInteger()+9, result.size()-1)
} else
{
x = 0
size = result.size() - 1
y = Math.min(size, 9)
}
def q=params.q
[countryInstanceList: result.getAt(x .. y), countryInstanceTotal:result.size(), q:params.q]
}else{
redirect(action: "list")
}
}
现在我有一个问题,当我按下下一个页面,然后我的PARAMS从搜索领域被清洗,结果为空。我试图发送字段值作为参数,但我的事情我做错了什么。
我的搜索页面看起来像:
<g:form action="search">
<div class="search" >
Search Country
<g:hiddenField name="q" value="${params.q}" />
<input type="text" name="q" value="${params.q}" />
<input type="submit" value="Search"/>
</div>
</g:form>
...... ......
Emmmm,你为什么要用搜索引擎,后来用HQL查询? – 2012-08-02 14:36:31