Grails default mapping is this:
"/$controller/$action?/$id?" {}
<g:link controller="book" action="show" id="book.id">
${book.title}
</g:link>
Sure this is the standard way. But now lets change the URL mapping by replacing the default mapping:
"/$book/$id?"(controller: "book", action: "show")
It's stil working! Grails knows, that URLs, which are pointing to BookControllers's show action have to be of the declared structure and thus, the link tag will create a URL like 'http:localhost:8080/myapp/book/1'.
Ok, let's go on. What else can we do with this?
By default the URL 'http:localhost:8080/myapp/book/list?year=2009' will point to the list action of BookController and the URL parameter year will be available with
params.year
in the action. To create this URL you can use the link tag again:
<g:link controller="book" action="list" params="[year: "2009"]">
Books released in 2009
</g:link>
"/$books/$year?"(controller: "book", action: "list")
No comments:
Post a Comment