tags:

views:

37

answers:

2

I have a test grails app setup with a context of "/testapp". When I add a link in my gsp that references / it does not go to the root of my grails.app.context, but to the root of my grails.serverURL property.

For example given a link with href "/css/main.css"

I would expect that this link would actually look in localhost:8080/testapp/css/main.css instead of localhost:8080/css/main.css

Is there a way that I can get references to / to start at my grails.app.context vs the grails.serverURL?

+2  A: 

the question is how do you add your links into your gsps?

We do things like

<link rel="stylesheet" href="${resource(dir: 'css', file: 'stylesheet1.css')}"/>

and

<g:javascript library="prototype"/>

by using the g:javascript and resource tags and methods, you tell grails to set the path for you...

I suspect you are just putting standard tags in...

goto

http://grails.org/doc/latest/

and, under tags in the left hand nav, look for resource and/or javascript to get an idea (its difficult to link directly in to the docs...:()

hvgotcodes
Thanks for the reply. We are using the tag libraries, but we have a situation with an external library that has a hardcoded /path/to/css that we cannot change. Sounds like we will have to find a work around.
ibuck
A: 

use the request contextPath value on the page

${request.contextPath}

and then prepend the additional host information if necessary to construct the complete url

Aaron Saunders