Я пытался следовать пошаговым инструкциям в Grails In Action (http://www.manning.com/gsmith2/GiA2E_meap_ch01.pdf), а строительные леса, описанные в разделе 1.5.1, стр. 21-23, похоже, мне не подходит.
Я добавил static scaffold = true
в QuoteController.groovy
, как было предложено. Затем выполнил grails run-app, и когда я перейду к localhost:8080/qotd/quote/list
, я получаю ошибку 404 (вместо рисунка 1.11 в pdf) следующим образом:
HTTP Status 404 - /qotd/quote/list
type Status report
message /qotd/quote/list
description The requested resource is not available.
Apache Tomcat/7.0.42
Вот QuoteController.groovy
:
package qotd class QuoteController { static scaffold = true def index() { redirect(action: "home") } def home() { render "Real Programmers do not eat Quiche" } def random() { def allQuotes = Quote.list() def randomQuote def n = allQuotes.size() if (n > 0){ def randomIdx = new Random().nextInt(n) randomQuote = allQuotes[randomIdx] } else{ String str = "Real Programmers Don't Eat Quiche" + n randomQuote = new Quote(author: "Anonymous", content: str) } [quote: randomQuote] } }
Однако переход к localhost:8080/qotd/quote/create
работает нормально (соответствует рисунку 1.12 в PDF-файле), и я могу создать новую цитату.
Я использую следующие версии:
Версия приложения: 0.1
Версия Grails: 2.3. 1
Groovy-версия: 2.1.8
Версия JVM: 1.7.0_45
Это ошибка в Grails или мне что-то не хватает?
Я новичок в Groovy и Grails, и я буду очень признателен за любую помощь. Спасибо!