سؤال

I have a grails 2.3.8 app.

It has a view: views/rte/subscriptions.gsp

I have a controller: controllers/RTEController.groovy

RTEController contains an action:

def subscriptions() { 

}

UrlMappings.groovy contains:

    "/rte" (controller: "rte") {
        action = [GET: "subscriptions"]
    }

When I browse to:

http://localhost:8080/MYAPP/rte 

I get a 404 error.

Why is the url mapping not working?

هل كانت مفيدة؟

المحلول

Since CamelCase format is not used for controller name. The mapping has to match with the exact name of the controller. Modify the url mapping as below:

"/rte" (controller: "RTE") { //controller name all CAPS
    action = [GET: "subscriptions"]
}

Also note, this is applicable during dependency injection as well. For example, if there is a service named RTEService, then it can only be injected in other classes as

def RTEService //instead of def rteService or def rTEService
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top