brw*_*dev 5 css grails layout spring-security gsp
我正在使用 spring-security-core 插件,并在/views/login/denied.gsp下创建了一个自定义的Denied.gsp页面。如果我直接通过/login/denied进入该页面,我可以看到布局已应用。但是,如果我尝试访问受限页面并且被路由到拒绝的.gsp,它只会呈现确切的 html,而不处理布局。
<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>
Run Code Online (Sandbox Code Playgroud)
我将这些设置为 false,以便默认情况下不会锁定所有内容:
grails.plugin.springsecurity.rejectIfNoRule = false
grails.plugin.springsecurity.fii.rejectPublicInvocations = false
Run Code Online (Sandbox Code Playgroud)
管理员控制器:
@Secured(['ROLE_ADMIN'])
class AdminController {
def index() {
}
}
Run Code Online (Sandbox Code Playgroud)
例如,我以 ROLE_USER 身份登录,然后转到 /admin,它正确地拒绝了我。然而,它的页面上没有样式。
没有关于 css、js 等的附加规则。
我不明白为什么在这种情况下不应用样式。有任何想法吗?
首先熟悉这个https://github.com/grails-plugins/grails-spring-security-core/issues/177
作为解决方法,我建议您执行以下提到的步骤。
在您的UrlMappings.groovymake 修改中:
"500"(controller: "error", action: "denied")
Run Code Online (Sandbox Code Playgroud)
在您的Config.groovy文件中覆盖errorPage属性
grails.plugin.springsecurity.adh.errorPage = null
Run Code Online (Sandbox Code Playgroud)
并在控制器中添加操作:
def denied() {
render(view: '/login/denied')
}
Run Code Online (Sandbox Code Playgroud)
这对我有用。
| 归档时间: |
|
| 查看次数: |
1416 次 |
| 最近记录: |