これが私の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
のように入力すると、abc
は にマップされず、params.id
をレンダリングするとparams
、空の map が表示されます[:]
。フィールドがにマップされるときにURLが入力された場合http://localhost:8080/g24/ewhet/show?id=abc
、次のようになります。id
params.id
['id':'abc']
したがって、 Grails ドキュメントのセクション 7.4.3 に従って、URL でマップを使用せずに ( のように)、マップのid
パラメーターにマップされた URL の最後の部分を取得したいだけです。params
id=abc
バックエンドでスキーマレス mongodb を使用しているため、ドメイン クラスがないことに注意してください。