I have created a folder named 'content' under grails-app/view and serve all gsp files from there which does not require a controller action.
In order to serve this view, I had added a UrlMapping "/content/$view"(controller:"content"). This enables me to call /my-app/content/staticGSP directly without an actual ContentController. This is working fine for some time without any issues.
Today, I wanted to add a filter which would redirect to a view under content folder directly. I added a before closure in MYFilter.
all(controller: "*") {
before = {
if(onSomeCond){
redirect(controller: 'content', action: 'seamless')
return false
}
return true
}
}
This filter works fine if I try a Url http://localhost:8080/my-app/home/index. Here I have a HomeController in my app.
But, if I try http://localhost:8080/my-app/content/anotherview, then Filter just responds with a 404. I am not able to figure out why this is.
Any insight would be really helpful.
Thanks, Abhijith
Apparently
http://localhost:8080/my-app/content/anotherviewmatches the url mapping"/content/$view"(controller:"content")and you do not have the viewanotherviewinstaticfolder.anotherviewis insidecontentfolder. Hence, 404.Is the name of the folder you added for static content is
contentorstatic? Your question saysstatic