2014-02-05 56 views
4

我使用彈簧安全核心插件,我已經/views/login/denied.gsp下創建一個自定義denied.gsp頁。如果我通過/login/denied直接進入頁面,我可以看到應用了佈局。但是,如果我嘗試訪問受限制的頁面並將其路由到denied.gsp,它只會呈現精確的html而不處理佈局。定製denied.gsp風格不渲染

<html><head> 
     <title>Denied</title> 
     <meta name="layout" content="main"> 
    </head> 
    <body> 
     <section class="breadcrumb p07"> 
      <p><a href="/">Home</a> Denied</p> 
     </section> 
     <section class="content"> 
      <p>Sorry, you're not authorized to view this page.</p> 
     </section> 

</body></html> 

我的這些設置爲false,讓一切都不會被默認鎖定:

grails.plugin.springsecurity.rejectIfNoRule = false 
grails.plugin.springsecurity.fii.rejectPublicInvocations = false 

AdminController:

@Secured(['ROLE_ADMIN']) 
class AdminController { 

    def index() { 

    } 
} 

因此,例如,我的身份登錄ROLE_USER然後去/管理,它正確地否認了我。然而,它在頁面上沒有樣式。

有關於CSS,JS等

我想不通爲什麼造型是不是在這種情況下,沒有應用其他規則。有任何想法嗎?

+0

@JoshuaMoore是的,我 – brwngrldev

+0

你有沒有證實沒有到CSS和其他樣式相關的元素不受限制的訪問?如果您發佈了您的請求映射,這將會很有幫助。考慮到默認情況下的所有內容都被完全鎖定。 –

+0

@JoshuaMoore我已更新我的問題 – brwngrldev

回答

4

首先熟悉這個https://github.com/grails-plugins/grails-spring-security-core/issues/177

作爲一種變通,我會建議你下面提到步驟。

在你UrlMappings.groovy進行修改:

"500"(controller: "error", action: "denied") 

在你Config.groovy文件覆蓋errorPage財產

grails.plugin.springsecurity.adh.errorPage = null 

而且在你的控制器中添加操作:

def denied() { 
    render(view: '/login/denied') 
} 

這對我的作品。