當我沒有權限訪問視圖時,我收到此消息。如何編輯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