?? - link
?? Description
Creates a html anchor tag with the href set to based on the parameters specified
???????????????href???????html??????????
????? Parameters
- action (??) - ????????????????????????????????????????? the name of the action to use in the link, if not specified the default action will be linked
- controller (??) - ???????????????????????????????????????????the name of the controller to use in the link, if not specified the current controller will be linked
- id (??) - ????????id?The id to use in the link
- params (??) - ?????????????Map? A map containing request parameters
- url (??) - action,controller,id????Map?A map containing the action,controller,id etc.
? Examples
Example controller for an application called "shop":
"shop"??????????????????????????
class BookController {
def defaultAction="list"
def list = { [ books: Book.list( params ) ] }
def show = { [ book : Book.get( params['id'] ) ] }
}
Example usages for above controller:
??????????????
<g:link action="show" id="1">Book 1</g:link>
<g:link controller="book">Book Home</g:link>
<g:link controller="book" action="list">Book List</g:link>
<g:link url="[action:'list',controller:'book']">Book List</g:link>
<g:link action="list" params="[sort:'title',order:'asc']">Book List</g:link>
Example as a method call in GSP only:
GSP??????????????
<%= link(action:'list',controller:'book') { 'Book List' }%>
Results in:
????
<a href="/shop/book/list">Book List</a>