See the light - agile, industrial strength, rapid web application development made easy

(Quick Reference) # 7.4.12 Customizing URL Formats - Reference Documentation Authors: Graeme Rocher, Peter Ledbrook, Marc Palmer, Jeff Brown, Luke Daley, Burt Beckwith, Lari Hotari Version: 2.3.8 ## 7.4.12 Customizing URL Formats The default URL Mapping mechanism supports camel case names in the URLs. The default URL for accessing an action named `addNumbers` in a controller named `MathHelperController` would be something like `/mathHelper/addNumbers`. Grails allows for the customization of this pattern and provides an implementation which replaces the camel case convention with a hyphenated convention that would support URLs like `/math-helper/add-numbers`. To enable hyphenated URLs assign a value of "hyphenated" to the `grails.web.url.converter` property in `grails-app/conf/Config.groovy`.

    // grails-app/conf/Config.groovygrails.web.url.converter = 'hyphenated'
Arbitrary strategies may be plugged in by providing a class which implements the UrlConverter interface and adding an instance of that class to the Spring application context with the bean name of `grails.web.UrlConverter.BEAN_NAME`. If Grails finds a bean in the context with that name, it will be used as the default converter and there is no need to assign a value to the `grails.web.url.converter` config property.

    // src/groovy/com/myapplication/MyUrlConverterImpl.groovypackage com.myapplicationclass MyUrlConverterImpl implements grails.web.UrlConverter {    String toUrlElement(String propertyOrClassName) {
            // return some representation of a property or class name that should be used in URLs…
        }
    }

    // grails-app/conf/spring/resources.groovybeans = {
        "${grails.web.UrlConverter.BEAN_NAME}"(com.myapplication.MyUrlConverterImpl)
    }
| Quick Reference (hide)