如何在grails 3.3.9中显示自定义的错误页面,以禁止URL访问

问题描述 投票:0回答:1

我的grails 3.3.9应用程序具有使用Spring Security通过不同的基于ROLE的访问来实现的不同模块。

通过ROLE_ADMIN访问的AdminController。如果非管理员用户登录并尝试访问Admin URL,则grails显示

[Image] Grails Error Message: Sorry, you're not authorized to view this page.

我想显示我的自定义消息。

Sorry, you're not authorized to view this page. [Image: ]

application.groovy

Custom Message: 403 Access Forbidden
grails spring-security grails-plugin grails-3.3
1个回答
0
投票

在URlMappings中,您可以设置到响应代码的映射,并选择要响应的控制器或视图-例如:

403 Access Forbidden

参见:grails.plugin.springsecurity.interceptUrlMap = [ [pattern: '/user/**', access: ['IS_AUTHENTICATED_FULLY']], [pattern: '/role/**', access: ['ROLE_ADMIN']], [pattern: '/', access: ['IS_AUTHENTICATED_FULLY']], [pattern: '/admin/*', access: ['ROLE_ADMIN']]]

© www.soinside.com 2019 - 2024. All rights reserved.