Scenario:
I want to create g:link
which will redirect to
www.xyz.com/controller/action/title_of_question
instead
www.xyz.com/controller/action/id_of_question
I know that later one can be created easily configuring id
param of the g:link
.
Please note that title_of_question
is String
separated with hyphen (-)
Can anybody suggest me how to achieve it?
Short answer: yes, we can :)
If you have no rule in UrlMappings.groovy
which defines id
as Long
or Integer
you can create links with String
identifier like below:
<g:link controller="controllerName" action="show" id="someName">Link!</g:link>
And define controllers action with identifier as String
:
def show(String id) {
...
}