我有一个过滤器,我想过滤除将我带到登录页面的一个操作以外的所有操作。
如果我以某种条件过滤所有页面,那么即使LOGIN页面也被过滤,因此由于条件不满足(用户未登录),它陷入了无限循环。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 ->
}
}
}
}
我要进行过滤,使其不过滤controller:"site",action:"index"
此URL并过滤其他所有内容。
提前致谢。
您可以反转过滤器规则,例如:
def filters = {
allExceptIndex(controller:"site",action:"index",invert:true) {
before = {
}
after = { Map model ->
}
afterView = { Exception e ->
}
}
}
参见文档http://grails.org/doc/latest/guide/theWebLayer.html#filters
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句