URL映射另一个重要的特性是自动定制 link 标签的行为。
以便改变这个映射而不需要改变所有的连接.
通过一个URL重写技术做到这点,从URL映射反转连接设计:static mappings = {
"/$blog/$year?/$month?/$day?/$id?"(controller:"blog", action:"show")
}
如果,你像下列一样使用连接标签:<g:link controller="blog" action="show" params="[blog:'fred', year:2007]">My Blog</g:link>
<g:link controller="blog" action="show" params="[blog:'fred', year:2007, month:10]">My Blog -October 2007 Posts</g:link>
Grails将自动重写URL通过适当的格式:<a href="/fred/2007">My Blog</a>
<a href="/fred/2007/10">My Blog - October 2007 Posts</a
>