当我没有权限访问视图时,我收到此消息。如何编辑grails中的unthorize GSP文件 - 初学者
Sorry, you're not authorized to view this page.
我想定制这个添加一些CSS等,使这个漂亮。我在哪里可以找到编辑这个视图?
当我没有权限访问视图时,我收到此消息。如何编辑grails中的unthorize GSP文件 - 初学者
Sorry, you're not authorized to view this page.
我想定制这个添加一些CSS等,使这个漂亮。我在哪里可以找到编辑这个视图?
被拒绝的页面存在于spring安全插件的登录文件夹中。如果您使用的是spring security 1.x,那么它在您的应用程序视图/登录/拒绝中,如果您使用的是spring security 2.x,那么它在Spring安全插件中,然后复制spring security插件中的views/login文件夹并粘贴它在你的应用程序视图页面中。然后
在UrlMappings
文件
"403"(controller: 'error', action: 'denied')
添加此并创建一个控制器ErrorController
class ErrorController {
def denied() {
render(view: '/login/denied')
}
}
中声明的Grails应用程序内的403页/ conf目录/ UrlMappings.groovy
"403"(view: '/403')
接下来,创建一个grails-app/views/403.gsp视图,它将包含在您访问的内容拒绝
<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<head>
<meta name="layout" content="main">
<title>Access Denied</title>
<link rel="stylesheet"
href="${resource(dir: 'css', file: 'stylesheet.css')}" type="text/css">
</head>
<body>
<h2>Sorry, you're not authorized to view this page.</h2>
</body>
</html>
页每次403错误是提高用户将看到的403.gsp 你可以做到这一点的内容从控制器如下:
//例从控制器内抛出403错误
def authenticateUser() {
if(!username.isValid(session)) {
return response.sendError(403)
}
}
希望它能帮助:)
500已经在那里了。我向'UrlMappings.groovy'添加了403错误,但它不起作用。我仍然看到旧的丑陋的错误信息。 – Illep
是的,我做到了。但仍然看到以前的错误消息 – Illep