I am using grails 2.0.1 and i tried linking to the html page using with the direct url="somefile.html> but it is not working out . How do i do it ?please help
You need to do two things:
web-app/somefile.html
, this is where you store raw files for the server.Instead of using a hard-coded URL, use the g.resource()
method or the <g:resource>
tag. In these cases, you'll use it like so:
<a href="${g.resource(file:'somefile.html')}">My Link</a>
The reason to use the g.resource
tag is it guarantees a correct link to the file. If you just hard code the file like href="somefile.html"
, then is is a relative path. If you are at the URI myapp/controller/action/foo
, it will look for the file under myapp/controller/action/somefile.html
.
Note: If you are using the cached-resources
plugin or something similar, you will find the output URL is not actually myapp/somefile.html
. The file is still accessible from that location, but the generated links will point to a static URL instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With