How do you get UrlMappings to ignore /css, /js and /images when you have added a route like this
UPDATE
"$username"(controller:"profile",action:"show") {
constraints {
username(notInList:['css','js','images'])
}
}
Can I use notInList? I how do I reverse inList?
From the manual:
If you are using wildcard URL mappings then you may want to exclude certain URIs from Grails' URL mapping process. To do this you can provide an excludes setting inside the UrlMappings.groovy class:
class UrlMappings = {
static excludes = ["/images/*", "/css/*"]
static mappings = {
…
}
}
This allows you to exclude directories from the mapping.
Update If you want to use a regex, this might work better:
constraints {
username(matches:"^(?!(js|css|images)/).*")
}
This regex matches anything that doesn't start with js/
, css/
, or images/
. It matches via zero-width negative lookahead ((?!…)
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With