(Quick Reference) # 8.3.12 Customizing URL Formats Version: 6.0.0 ## 8.3.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/application.groovy`. grails-app/conf/application.groovy
    grails.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/main/groovy/com/myapplication/MyUrlConverterImpl.groovy
    package com.myapplication

    class 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.groovy
    beans = {
        "${grails.web.UrlConverter.BEAN_NAME}"(com.myapplication.MyUrlConverterImpl)
    }
| Quick Reference (hide)