0
我有一个运行的tomcat在localost
。设置没有控制器的过滤器
我希望编写一个grails过滤器,以便当用户转到localhost/filter/
时拦截该调用并进行一些处理。我创建了一个过滤器是conf
文件夹
class TestFilters {
def filters = {
filter(uri:'/filter') {
before = {
}
after = {
}
afterView = {
}
}
}
}
内设置此功能后,当我去localhost/filter/
我只得到404
错误。
我在哪里犯错?
在此先感谢
没有其他办法可以在不创建控制器的情况下做到这一点?有没有办法通过更改'web.xml'文件来做到这一点? – sriram
如果你真的想忽略整个MVC模式,你可以将url映射直接链接到视图。看看[这个SO答案](http://stackoverflow.com/a/9890039/1230366)我发现... – aiolos
感谢您的答案。但是有什么办法可以将过滤器路由放入'UrlMapping'中? – sriram