【发布时间】:2015-09-10 13:33:05
【问题描述】:
大家好,
我正在尝试将参数从 URL 传递给 findAll() 方法。
LINE3我使用 findAll() 来定义鼠标。
LINE2 def house 在我进入页面时会带入参数DELAWARE:http://localhost:8080/TestApp/home/county/DELAWARE
House 将只显示一个实例而不是列表。无论如何传递 url 而不是 ["DELAWARE"]? (请参阅第 3 行)谢谢 :)
def county() {
def house = Home.findByCounty(params.id) //sends only user related address to view
def mouse = Home.findAll("from Home h where h.county= ?", ["DELAWARE"]);
if (!house) {
response.sendError(404)
} else {
[house:house, mouse:mouse ]
}
}
工作代码 +1 @Danilo
def county() {
def house = Home.findAllByCounty (params.id) //sends only county specified thru URL e.g. http://localhost:8080/TestAPP/home/county/DELAWARE
if (!house) {
response.sendError(404)
} else {
[house:house ]
}
}
【问题讨论】:
-
我不明白你想要什么。老实说
标签: grails