mongodbgrailsurlmappings.groovy

Grails URL id field not getting mapped to params


Here is my 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')
    }
   }

Here is my ewhetController's show action:

class EwhetController {
    def index(){

    }
    def show(){
            def ctx = startAsync()
            ctx.start {
                render params
                //render "this invoked!!"
                ctx.complete()
            }
        }
}

Now when I enter the url as: http://localhost:8080/g24/ewhet/abc The abc does not get mapped to the params.id and when I render params, I get an empty map [:] . In case if url is entered as http://localhost:8080/g24/ewhet/show?id=abc the id field gets mapped to the params.id and I get:

['id':'abc']

So I just want to get the last part of the url mapped to the id parameter in params map without using any map in the url (like id=abc) as per Section 7.4.3 in Grails documentation So how is that possible and why is my approach not working?

Kindly note that I do not have any domain classes as I am using schemaless mongodb at my backend.


Solution

  • Try to reload the app after changing the UrlMappings.groovy to assure the new config is correctly loaded.