<g:createLinkTo dir="images" file="icon.png" />
This will render:
/myapp/images/icon.pngThis means that <YOUR-GRAILS-PROJECT>/web-app/images/icon.png is the one accessed and must exist. Here is the breakdown of the components:
We can use it like this
<img src="${createLinkTo(dir:'images', file:'icon.png'}">
This will render:
<img src="/myapp/images/icon.png">
Here is another example:
<script> function viewImage() { window.location.href = '<g:createLinkTo dir="images" file="icon.png" />'; } </script>
This will render:
<script> function viewImage() { window.location.href = '/myapp/images/icon.png'; } </script>