Search code examples
grailsurl-mapping

Grails URLMapping deep path


I have a URL like:

/test/abs/rdc/tx.js

and I need to be able to get the /abs/rdc/tx.js part for my controller.

I tried (in URLMapping):

/test/$target**

and it returns everything but the .js

I have

grails.mime.file.extensions = true 

Any ideas?

UrlMapping and file name extension didn't work as it always returns .html


Solution

  • Grails 2.0 has made some changes to the way the format is parsed. Using the example from the link you provided, just update the code to use response.format:

    def path = params.path
    if (!FilenameUtils.getExtension(path) && response.format) {
      path += ".${response.format}"
    }
    

    More info is in the manual under Content Negotiation. Scroll down to the section titled Request format vs. Response format.