我有一個基本的grails入口頁面,顯示了票務系統的事件列表。Grails分頁問題,按鈕沒有渲染,鏈接似乎也不工作
我遇到的一個PAGINATE按鈕問題第1頁2個鏈接不會看起來像按鈕和下一個字也只是一個超鏈接,它不會從2
隔開其次,鏈接他們自己,一旦點擊他們不起作用。他們拋出一個錯誤頁:
--------------------------------
HTTP Status 404 - /tictoc/store/activeEvents
type Status report
message /tictoc/store/activeEvents
description The requested resource (/tictoc/store/activeEvents) is not available.
Apache Tomcat/7.0.25
--------------------------------
![page UI][1]
[1]: http://i.stack.imgur.com/ABPlB.png
這裏是Show.gsp ...的PAGINATE部分,我想我的問題是:
<%@ 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>
這裏是控制器... 我不知道問題是否存在,但我認爲 我會包括它以防萬一。
package tictoc
import tictoc.Event
class StoreController {
Event event
static defaultAction = "activeEvents"
def show = {
log.error 'exec activeEvents'
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.count()
def eventList = Event.getAll()
return [events:eventList,
totalEvents:total,
active:params.active]
}
}
按鈕現在看起來。那很好。我改變了頁面/分頁以使用show closure ...,現在下一頁工作...除了它顯示相同的項目。我似乎無法更改顯示每頁的項目數量。我試圖def最大= Math.min(params.max?.toInteger()?:5,5) – user1260085 2012-03-12 18:14:59
正確的是,需要另一個變化。在你的控制器中,將'Event.getAll()'替換爲'Event.list(params)' – 2012-03-12 19:03:09
另外,我編輯了我的答案,以包含一個Controller列表閉包的示例。您需要根據您的具體情況對其進行調整。 – 2012-03-12 19:36:52