User-Friendly URLs

We now need to provide a way to access our event page using a simple URL. The way it stands now, once the application is deployed, the URL to a specific event’s page looks something like this:

http://TekDays.com/tekEvent/show/5024753

(OK, the id might not be quite that large at first, but we’re thinking positive here.) Our customer would like us to get to something more like http://TekDays.com/events/MyTekEvent. This will make it easier for the event organizers and volunteers to plaster links all over the Internet for their event.

As we have come to expect, Grails provides a simple way to do this. Every Grails application has a UrlMappings class, which uses a DSL[73] to build URL mappings. The conventional Grails mappings ...

Get Grails 2: A Quick-Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.