這裏是我的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? –