"Fossies" - the Fresh Open Source Software Archive

Member "grails-core-5.2.4/grails-docs/src/test/resources/docs/ref/Tags/createLinkTo.html" (14 Sep 2022, 62751 Bytes) of package /linux/www/grails-core-5.2.4.tar.gz:

Caution: In this restricted "Fossies" environment the current HTML page may not be correctly presentated and may have some non-functional links. You can here alternatively try to browse the pure source code or just view or download the uninterpreted raw source code. If the rendering is insufficient you may try to find and view the page on the grails-core-5.2.4.tar.gz project site itself.

(Quick Reference)


Deprecated: Use resource instead.


Creates a link that can be used where necessary (for example in an href, JavaScript, Ajax call etc.)


Example controller for an application called "shop":

Example usages for the "shop" app:

// generates "/shop/css/main.css"
<g:createLinkTo dir="css" file="main.css" />

// generates "http://portal.mygreatsite.com/css/main.css"
<g:createLinkTo dir="css" file="main.css" absolute="true"/>

// generates "http://admin.mygreatsite.com/css/main.css"
<g:createLinkTo dir="css" file="main.css" base="http://admin.mygreatsite.com"/>

Example as a method call in GSP only:

<link type="text/css" href="${createLinkTo(dir:'css',file:'main.css')}" />

Results in:

<link type="text/css" href="/shop/css/main.css" />



  • dir (optional) - the name of the directory containing the resource

  • file (optional) - the name of the resource file

  • absolute (optional) - If true will prefix the link target address with the value of the grails.serverURL property from application.groovy, or http://localhost:<port>; if there is no setting in application.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 the absolute property if both are specified.