Search code examples
grailsmodel-view-controllergspgrails-controller

Grails controller URL not found


I have the following Grails 2.3.6 app structure (besides the normal/default Grails structure):

myapp/
    grails-app/
        controllers/
            com/me/myapp/fizz/
                BuzzController.groovy
        views/
            foo/
                foo.gsp

In BuzzController:

class SomeController {
    def index() {
        // Do a bunch of stuff

        render(
            view: "foo",
            model: foo
        )
    }
}

When I run grails run-app and open a browser to

http://localhost:8080/myapp/buzz

Grails serves back my custom 404 Not Found page. What's going on, and what can I do to fix it?


Solution

  • In your controller put your code like below and see what happens.

    render(
                view: "/foo/foo",
                model: 
            )
    

    If your controller name and the view folder are same then you dont need to give /foo/foo. Just writing "foo" should be fine.

    PS. I have not tried this now, but it should work.