1

这是我的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')
    }
   }

这是我ewhetControllershow行动:

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 abcdoesn't get mapped to theparams.id并且当我 render 时params,我得到一个空的 map [:]。如果http://localhost:8080/g24/ewhet/show?id=abcid字段映射到时输入 url params.id,我会得到:

['id':'abc']

因此,我只想根据Grails 文档中的第 7.4.3 节将 url 的最后一部分映射到map 中的id参数,而不使用 url 中的任何映射(如 )那么这怎么可能,为什么我的方法不起作用?paramsid=abc

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

4

1 回答 1

1

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

于 2013-07-11T12:58:28.527 回答