In 6.4.6 Mapping Wildcards is written that you exclude URIs like this:
static excludes = ["/images/**", "/css/**"]
But this didn’t work for me. Looking at the source code (UrlMappingsFilter) I found out, that the exclude is no wildcard pattern matching and only a startsWith matching:
for (String excludePattern:excludePatterns){
if (uri.equals(excludePattern)||
(excludePattern.endsWith("*")&&
excludePattern.substring(0,excludePattern.length()-1).
regionMatches(0,uri,0,excludePattern.length()-1))){
processFilterChain(request, response, filterChain);
return;
}
}
So the correct way is with one asterisk:
static excludes = ["/images/*", "/css/*"]
March 24, 2010 at 12:15 am
Thanks for the blog post, Martin! I just ran into this problem myself with Grails 1.2 – really messes with your brain when something is documented as working, but doesn’t. Thanks for digging in and having a look at the source.
Is there a bug entered for this in the Grails Jira?
Cheers,
Timo
March 25, 2010 at 4:26 pm
Hi Tim,
without checking I assumed there would be a ticket. But after checking JIRA, I saw that there wasn’t one. So thanks for the comment. I raised now a bug: http://jira.codehaus.org/browse/GRAILS-6094.
Regards Martin
May 20, 2010 at 7:17 am
The documentation was corrected in version 1.3.2.
Thanks to Burt Beckwith.