我有一个过滤器,我想过滤除了带来登录页面的ONE之外的所有操作.
如果我过滤掉所有具有某些条件的页面,那么甚至LOGIN页面也会被过滤掉,因此当条件未满足时它会卡在infinte循环中(用户未登录).
session.getAttribute("CurrentEmployeeIds")它告诉用户是否登录
我在这里过滤:
class LoginFilters {
def filters = {
all(controller:'dashboard', action:'*') {
before = {
if (session.getAttribute("CurrentEmployeeIds")==null) {
redirect(controller:"site",action:"index")
return false
}
}
after = { Map model ->
}
afterView = { Exception e ->
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我希望以这样的方式过滤它不过滤controller:"site",action:"index"此网址并过滤其他所有内容.
提前致谢.
Igo*_*nov 11
您可以反转过滤规则,例如:
def filters = {
allExceptIndex(controller:"site",action:"index",invert:true) {
before = {
}
after = { Map model ->
}
afterView = { Exception e ->
}
}
}
Run Code Online (Sandbox Code Playgroud)
请参阅文档http://grails.org/doc/latest/guide/theWebLayer.html#filters
| 归档时间: |
|
| 查看次数: |
10498 次 |
| 最近记录: |