Java Grails分页问题

Java Grails分页问题,java,grails,Java,Grails,//这是domain类,我正在使用活动字段进行withCritera搜索。我希望它是一个布尔值,但我不确定它是否有效 I have a simple paginate issue and get the following error... Hoping for some advice. I am relearning grails using version 2.1 and when I attempt to make a page with the paginate section is

//这是domain类,我正在使用活动字段进行withCritera搜索。我希望它是一个布尔值,但我不确定它是否有效

I have a simple paginate issue and get the following error... 
Hoping for some advice. I am relearning grails using version 2.1 and when I attempt to make a page with the paginate section is it failing.


Error 500: Internal Server Error
URI
/tictoc/
Class
groovy.lang.MissingMethodException
Message
No signature of method: tictoc.Event.withCritera() is applicable for argument types: (tictoc.StoreController$_closure2_closure3) values: [tictoc.StoreController$_closure2_closure3@10cea05] Possible solutions: withCriteria(groovy.lang.Closure), withCriteria(java.util.Map, groovy.lang.Closure)
Around line 27 of grails-app\controllers\tictoc\StoreController.groovy
24:        
25:        def total = Event.countByActive(true)
26:        
27:        def eventList = Event.withCritera {
28:        
29:            eq 'active', params.active
30:            projections {
Around line 13 of grails-app\controllers\tictoc\StoreController.groovy
10:    def show = {
11:    
12:        log.error 'exec activeEvents'
13:        activeEvents()
14:
15:    }
16:
//这是GSP,分页部分未显示下一个/上一个按钮:

package tictoc

import java.math.BigInteger

class Event implements Cloneable {

    Integer id
    String name
    Date startDate
    Date endDate
    String desc
    String active 

    static constraints = {
        name(nullable:true)
        startDate(nullable:true)
        endDate(nullable:true)
        desc(nullable:true)
        active(nullable:true)
    }

    public String toString(){
        return "id:" + this.id + 
               " name:" + this.name + 
               " startDate:" + this.startDate +
               " endDate:" + this.endDate;
    }

    public int hashCode() {
        int hash = 1
        hash = hash * 31 + id.hashCode()
        hash = hash * 31 + name.hashCode()
        hash = hash * 31 + this.startDate
        hash = hash * 31 + this.endDate
        return hash
    }

    public boolean equals(Object anObject) {

        if (anObject != null &&
            anObject instanceof Event)
        {
            Ticket aThing = (Ticket)anObject;
            return (this.id == aThing.id) && 
                   (this.name == aThing.name) && 
                   (this.startDate == aThing.startDate) && 
                   (this.endDate == aThing.endDate)
        }

        return false;
    }
}

售票处
事件
开始
终点
描述
${event.name}
${event.desc}
这是控制器,我将默认页面设置为activeEvents:
一揽子tictoc
导入tictoc.Event
类存储控制器{
事件
静态defaultAction=“activeEvents”
def activeEvents={
log.error“exec activeEvents”
def max=Math.min(参数max?.toInteger()?:10100)
def offset=参数offset?.toInteger():0
def total=Event.countByActive(真)
def eventList=Event.withCritera{
均衡器“激活”,参数“激活”
投影{
事件{
订单“名称”
}
}
最大结果最大值
第一结果偏移量
}
return[events:eventList,
totalEvents:total,
活动:参数。活动]
}
}

您拼写不正确。

您拼写不正确。

学习阅读错误消息是grails中的一项重要技能:)它们通常会引导您朝着正确的方向前进!在grails中,学习阅读错误消息是一项非常重要的技能:)它们通常会引导您朝着正确的方向前进!
<%@ page import="tictoc.Store" %>
<!doctype html>
<html>
    <head>
        <meta name="layout" content="main">
        <g:set var="entityName" value="${message(code: 'store.label', default: 'Store')}" />
        <title><g:message code="default.show.label" args="[entityName]" /></title>
    </head>
    <body>

        <h1> Ticket Store </h1>

        <table border=0 class="eventsTable">
            <tr>
                <th>Event</th>
                <th>Start </th>
                <th>End </th>
                <th>Description</th>
            </tr>
            <g:each var="event" in="${events}">

            <tr>
                <td>${event.name}</td>
                <td><g:formatDate format="MM/dd/yyyy" date="${event.startDate}"/></td>
                <td><g:formatDate format="MM/dd/yyyy" date="${event.endDate}"/></td>
                <td>${event.desc}</td>
            </tr>

            </g:each>
        </table>

        <div class="paginateButtons">
            <g:paginate controller="store"
                action="activeEvents"
                params="[name:active]"
                total="${totalEvents}" />
        </div>
    </body>
</html>

Here is the controller and i set the default page to activeEvents :

package tictoc

import tictoc.Event 

class StoreController {

    Event event
    static defaultAction = "activeEvents"

    def activeEvents = {
        log.error 'exec activeEvents'
        def max    = Math.min(params.max?.toInteger() ?:10, 100)
        def offset = params.offset?.toInteger() ?: 0
        def total = Event.countByActive(true)
        def eventList = Event.withCritera {

            eq 'active', params.active
            projections {
                event {

                    order 'name'
                }
            }
            maxResults max
            firstResult offset
        }

        return [events:eventList, 
                       totalEvents:total,
                       active:params.active]
    }
}