这是我的URLmappings.groovy
class UrlMappings {
static mappings = {
"/$controller/$action?/$id?(.${format})?" {
constraints {
// apply constraints here
}
}
"/ewhet/$id"(controller : "ewhet", action : "show")
"/"(view: "/index")
"500"(view: '/error')
}
}
这是我ewhetController
的show
行动:
class EwhetController {
def index(){
}
def show(){
def ctx = startAsync()
ctx.start {
render params
//render "this invoked!!"
ctx.complete()
}
}
}
现在,当我将 url 输入为:http://localhost:8080/g24/ewhet/abc
The abc
doesn't get mapped to theparams.id
并且当我 render 时params
,我得到一个空的 map [:]
。如果http://localhost:8080/g24/ewhet/show?id=abc
在id
字段映射到时输入 url params.id
,我会得到:
['id':'abc']
因此,我只想根据Grails 文档中的第 7.4.3 节将 url 的最后一部分映射到map 中的id
参数,而不使用 url 中的任何映射(如 )那么这怎么可能,为什么我的方法不起作用?params
id=abc
请注意,我没有任何域类,因为我在后端使用无模式 mongodb。