Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I want to use an HTML page in my grails app. But Not able to

Tags:

grails

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

like image 736
Rajeev A N Avatar asked Mar 30 '12 02:03

Rajeev A N


1 Answers

You need to do two things:

  1. Make sure the file is stored under web-app/somefile.html, this is where you store raw files for the server.
  2. 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.

like image 51
OverZealous Avatar answered Oct 17 '22 04:10

OverZealous