谁能为我回答。
1.环境: Grails版本:2.3.7,JDK:1.8 2.程序文件: 我的Fiflter:
class MyFilterFilters {
def filters = {
all(controller:'*', action:'*') {
before = {
if (!controllerName) return true
if(!session.user && controllerName !='myRender')
{
println "------------------------"
render view:"/login"
return false
}
}
after = { Map model ->
}
afterView = { Exception e ->
}
}
}
}
我的控制器:
class MyRenderController {
def index() {
render text:"any message!!!"
return
}
}
我的登录页面(login.gsp):
This is login page
http://localhost:8080/renderTest/
why??? 答案 0 :(得分:0)
使用您的代码,您的登录页面也将被过滤,因此它将进入无限循环。
def filters = {
allExceptIndex(controller:"site",action:"index",invert:true) { // make proper change for controller and index
before = {
}
after = { Map model ->
}
afterView = { Exception e ->
}
}
}