这里是我的URLmappings.groovy
Grails的URL id字段没有得到映射到PARAMS
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()
}
}
}
现在,当我进入网址为:http://localhost:8080/g24/ewhet/abc
的abc
没有被映射到params.id
,当我渲染params
时,我得到一张空的地图[:]
。在情况下,如果作为http://localhost:8080/g24/ewhet/show?id=abc
的id
场被映射到params.id
输入网址,我得到:
['id':'abc']
所以,我只是想在params
地图映射到id
参数的URL的最后部分,而无需使用任何按照章节7.4.3中的url(如id=abc
)映射到Grails documentation那么这怎么可能?为什么我的方法不起作用?
请注意,我没有任何域类,因为我在后端使用了无模式mongodb。
如果您尝试注释掉第一个映射/$controller/$action?/$id?(.${format})?“? –
@FabianoTaioli无效! – rahulserver
如果您将映射更改为”/ ewhet/$ idx“(控制器:”ewhet“,动作:”显示“)它是idx在params? –