I have a running tomcat at localost.
I wish to write a grails filter such that when ever user goes to localhost/filter/ intercept the call and do some processing. I created a filter which is inside conf folder
class TestFilters {
def filters = {
filter(uri:'/filter') {
before = {
}
after = {
}
afterView = {
}
}
}
}
after setting this up when I go to localhost/filter/ I get only 404 error.
Where I’m making the mistake?
Thanks in advance
If you have no
FilterControllerthe urllocalhost/filterhas no ressource to show – so you get a 404 error. You have to adapt yourUrlMappingsso thatlocalhost/filteris a valid url of application.Add the following to
UrlMappings.groovy:Now – the url
localhost/filterpoints toyourActioninyourControllerand the filter should be applied.