views:

580

answers:

1

Given this UrlMapping:

"/foo/$foobar" {
    controller = "foo"
    action = "foo"
    constraints {
    }
}

Combined with this controller:

class FooController {
    def foo = {
        def foobar = params.foobar
        println "foobar=" + foobar
    }
}

And with these requests:

It seems like Grails cuts the "foobar" parameter at the first dot ("."). Is this intentional? Is there a work-around if I want to use parameters containing dots in my URL mappings?

+2  A: 

This can be solved by setting ...

grails.mime.file.extensions = false

... in Config.groovy.

It seems like Grails is trying to do some MIME magic behind the scene based on the file name suffix.

Updated: Some additional info from the Grails JIRA.

This is the offending code in UrlMappingsFilter.java:

    if(WebUtils.areFileExtensionsEnabled()) {
        String format = WebUtils.getFormatFromURI(uri);
        if(format!=null) {
            MimeType[] configuredMimes = MimeType.getConfiguredMimeTypes();
            // only remove the file extension if its one of the configured mimes in Config.groovy                                                                                                           
            for (MimeType configuredMime : configuredMimes) {
                if (configuredMime.getExtension().equals(format)) {
                    request.setAttribute(GrailsApplicationAttributes.CONTENT_FORMAT, format);
                    uri = uri.substring(0, (uri.length() - format.length() - 1));
                    break;
                }
            }
        }
    }

WebUtils.areFileExtensionsEnabled() returns the value of the "grails.mime.file.extensions" setting configured in Config.groovy.

knorv