rejectIfNoRule = true
时Grails应用中的无限循环问题
我尝试打开主页'/',我被重定向到'/ login / auth'并出现错误
错误310(net :: ERR_TOO_MANY_REDIRECTS):太多了 重定向。
似乎问题的根源位于org.codehaus.groovy.grails.plugins.springsecurity.RequestmapFilterInvocationDefinition.java中的initialize方法中,其中以下异常被静音。
Exception initializing; this is ok if it's at startup and due to GORM not being initialized yet since the first web request will re-initialize. Error message is "Cannot load Requestmaps, \"requestMap.className\" property is not set
不幸的是,第一个请求是带有无限循环的请求,那么如何初始化GORM的Requestmap?
环境:
我的Config.groovy:
Requestmaps:
new Requestmap(url: '/js/**', configAttribute: 'IS_AUTHENTICATED_ANONYMOUSLY').save()
new Requestmap(url: '/css/**', configAttribute: 'IS_AUTHENTICATED_ANONYMOUSLY').save()
new Requestmap(url: '/images/**', configAttribute: 'IS_AUTHENTICATED_ANONYMOUSLY').save()
new Requestmap(url: '/login/**', configAttribute: 'IS_AUTHENTICATED_ANONYMOUSLY').save()
new Requestmap(url: '/logout/**', configAttribute: 'IS_AUTHENTICATED_ANONYMOUSLY').save()
new Requestmap(url: '/', configAttribute: 'IS_AUTHENTICATED_ANONYMOUSLY').save()
答案 0 :(得分:3)
错误消息是“无法加载请求图”,“requestMap.className \”属性未设置
这就是您的错误的原因 - 当您在数据库中存储请求映射时,您需要Config.groovy
中的条目告诉spring安全插件Requestmap
域类的名称
grails {
plugins {
springsecurity {
securityConfigType = SecurityConfigType.Requestmap
// fully qualified class name of the Requestmap class
requestMap.className = 'com.example.Requestmap'
// these next two are the defaults but good to make them explicit anyway
requestMap.urlField = 'url'
requestMap.configAttributeField = 'configAttribute'
}
}
}