link
目的 Purpose
Creates an html anchor tag with the href
set based on the specified parameters.使用例 Examples
Example controller for an application called "shop":class BookController { def list() { [books: Book.list(params)] } def show() { [book : Book.get(params.id)] } }
<g:link action="show" id="1">Book 1</g:link><g:link action="show" id="${currentBook.id}">${currentBook.name}</g:link><g:link controller="book">Book Home</g:link><g:link controller="book" action="list">Book List</g:link><g:link controller="book" action="list" plugin="publishingUtils">Book List</g:link><g:link url="[action:'list',controller:'book']">Book List</g:link><g:link action="list" params="[sort: 'title', order: 'asc', author: currentBook.author]"> Book List </g:link><g:link controller="book" absolute="true">Book Home</g:link><g:link controller="book" namespace="publishing">Publishing Book Home</g:link><g:link controller="book" base="http://admin.mygreatsite.com">Book Home</g:link>
<%= link(action:'list',controller:'book') { 'Book List' }%>
<a href="/shop/book/list">Book List</a>
詳細 Description
属性 Attributes
action
(optional) - the name of the action to use in the link; if not specified the default action will be linkedcontroller
(optional) - the name of the controller to use in the link; if not specified the current controller will be linkednamespace
(optional) - the namespace of the controller to use in the linkplugin
(optional) - the name of the plugin which provides the controllerelementId
(optional) - this value will be used to populate theid
attribute of the generated hrefid
(optional) - the id to use in the linkfragment
(optional) - The link fragment (often called anchor tag) to usemapping
(optional) - The named URL mapping to use to rewrite the linkparams
(optional) - a Map of request parametersuri
(optional) - a relative URIurl
(optional) - a Map containing the action, controller, id etc.absolute
(optional) - Iftrue
will prefix the link target address with the value of thegrails.serverURL
property fromConfig.groovy
, or http://localhost:<port> if there is no setting inConfig.groovy
and not running in production.base
(optional) - Sets the prefix to be added to the link target address, typically an absolute server URL. This overrides the behaviour of theabsolute
property, if both are specified.event
(optional) - The name of a Webflow event to trigger for the flow associated with the givenaction
. Requires the Webflow plugin.