Mongodb Grails URL id字段未映射到参数

Mongodb Grails URL id字段未映射到参数,mongodb,grails,urlmappings.groovy,Mongodb,Grails,Urlmappings.groovy,这是我的URLmappings.groovy class UrlMappings { static mappings = { "/$controller/$action?/$id?(.${format})?" { constraints { // apply constraints here } } "/ewhet/$id"(controller : "ewhet", action : "show") "/

这是我的
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')
    }
   }
这是我的
EWEETController
显示的
操作:

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
时,我会得到一个空映射
[:]
。如果url输入为
http://localhost:8080/g24/ewhet/show?id=abc
id
字段映射到
params.id
,我得到:

['id':'abc']
因此,我只想将url的最后一部分映射到
params
映射中的
id
参数,而不使用url中的任何映射(如
id=abc
),如中第7.4.3节所述,那么这是怎么可能的,为什么我的方法不起作用


请注意,我没有任何域类,因为我在后端使用的是无模式mongodb。

请在更改UrlMappings.groovy后尝试重新加载应用程序,以确保正确加载新配置。

请在更改UrlMappings.groovy后尝试重新加载应用程序,以确保正确加载新配置。

如果您尝试注释输出第一个映射/$controller/$action?/$id?(.${format})?“?@FabianoTaioli不起作用!如果将映射更改为“/ewhet/$idx”(controller:“ewhet”,action:“show”)这是params?@FabianoTaioli中的idx。我已经解决了它。实际上,用修改过的URLMappings重新启动应用程序确实导致配置运行。教训是URLMappings.groovy没有被编译。你可以在这里给出答案来关闭它。如果你试图注释掉第一个映射/$controller/$action?/$id?(.${format})?”?@FabianoTaioli不起作用!如果将映射更改为“/ewhet/$idx”(控制器:“ewhet”,操作:“show”)它是params?@FabianoTaioli中的idx。我已经解决了这个问题。实际上,用修改过的URLMappings重新启动应用程序确实会导致配置运行。教训是URLMappings.groovy没有被编译。你可以在这里给出一个答案来关闭它。事实上,我发现了一个更通用的映射对我有效。我在URLMappings中添加了以下代码:“/$controller/$id”(操作:“show”)事实上,我找到了一个更通用的映射,它适合我。我将此代码添加到urlmappings:“/$controller/$id”(操作:“show”)