我有一个适用于所有 Controller 和 Action 的过滤器
all(controller:'*', action:'*')
如果满足特定条件,我正在尝试将用户重定向到另一个页面。但我收到上述错误。我插入了一些日志,以查看是否正在应用过滤器,并且我注意到
if(condition){} block was being executed multiple times and hence I believe the error is occurring.
请让我知道我该如何克服。谢谢。
最佳答案
我有代码,希望对您有所帮助
def filters = {
sessionCheck(controller: '*', action: '*') {
before = {
if(!(controllerName=="valueSet" && (actionName=="MATReleases" || actionName=="downloadReleases"))) {
if ("your condition") {
def url =new ApplicationTagLib().createLink(controller:'router',action:'sessionExpired')
render(status: 500, contentType: 'text/html', text: "<script>var sessionExpired ; window.location.href='${url}';</script>")
return false
}else{
}
} else {
println "else part"
}
}
}
}
关于grails - ERR_TOO_MANY_REDIRECTS在grails中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41954688/