2012-12-30 21 views
0

我與Grails的應用程序無限循環問題,當rejectIfNoRule = true 我嘗試打開主頁「/」,我重定向到/登錄/身份驗證「,並顯示錯誤Grails的,無限循環當rejectIfNoRule =真

錯誤310(net :: ERR_TOO_MANY_REDIRECTS):有太多 重定向。

這似乎是問題的根源位於在org.codehaus.groovy.grails.plugins.springsecurity.RequestmapFilterInvocationDefinition.java初始化方法,其中,下面的異常被沉默。

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的請求映射?

環境:

  • Groovy的版本:2.0.6
  • 的Grails 2.2.0
  • JVM:1.7.0_07賣方:Oracle公司
  • 操作系統:Linux
  • 彈簧安全 - 核心:1.2.7.3
  • spring-security-ui:0.2

我的Config.groovy:

  • grails.plugins.springsecurity.securityConfigType = 「Requestmap」
  • grails.plugins.springsecurity.rejectIfNoRule =真

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() 

回答

3

錯誤消息是「無法加載Requestmaps,\」requestMap.className \「屬性不是s等

這是你的錯誤的原因 - 當你在數據庫中存儲的請求地圖,您需要在Config.groovy告訴春季安全插件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' 
    } 
    } 
} 
+0

感謝的名義進入你尋求幫助 – mrok