我的 grails3.3.9
应用程序有不同的模块,它们ROLE
使用 spring security 实现了不同的基于访问。
AdminController 通过访问ROLE_ADMIN
。如果非管理员用户登录并尝试访问,Admin URL
则 grails 显示
[Image]
Grails 错误消息:Sorry, you're not authorized to view this page.
我想显示我的自定义消息。
[Image: ]
自定义消息:403 Access Forbidden
应用程序.groovy
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']]]
URL映射
"500"(controller: "error", action: "internalServerError")
"404"(controller: "error", action: "notFound")
"403" (controller: "error", action: "forbidden")
"403"(view: "/error/forbidden")
我分别为403
.
500 & 404
工作正常。