Ron
Ron

Reputation: 513

Using directory in grails url mappings

I'm new to Grails, and formerly used Codeigniter for web application development.

I want to know if it's possible to map my url and controllers in a way like this.

So I have a folder in controllers called dashboard, in dashboard I have controllers like: users, groups, settings

So the setup in controllers or project.dashboard is

project.dashboard/Groups.groovy

I want corresponding views like this:

views/dashboard/groups/index.gsp

How would I use the URL mapping to set that up, this is what I have no which isn't working for me.

"/dashboard/$controller/$action?/$id?" {
            constraints {
                // apply constraints here
            }
        }

Upvotes: 2

Views: 745

Answers (1)

Denis Fuenzalida
Denis Fuenzalida

Reputation: 3346

If you want subfolders inside controllers, that is effectively a change on the package your controller classes.

If you create a controller on grails-app/controllers/dashboard/GroupsController.groovy, the class belongs to the dashboard package:

package dashboard

class GroupsController {
  // ...
}

Adding extra folders in the views does not make much sense, the folders on grails-app/views are all-lowercase versions of the names of the controllers (eg. "groups" contains the views of "GroupsController"):

$ ls grails-app/views
groups/    layouts/    tasks/    users/   

Upvotes: 2

Related Questions