In a custom tag, I am receiving as a parameter the url of a file, which I need to open.
I have this
/content/data.html
which is the output from
${createLinkTo(dir:'content',file:'data.html')}:
and I need the 'server path':
C:\mygrailsapp\web-app\content\data.html
You can use the Spring application context to find resources. This works if it's under web-app folder:
class FooController {
def grailsApplication
def myAction = {
String path = params.path // '/content/data.html'
def resource = grailsApplication.mainContext.getResource(path)
String text = resource.inputStream.text
...
}
}