我正在尝试禁用Searchable插件默认搜索页面(http:// localhost/searchable /),但还没有找到办法.任何人都知道如何做到这一点,最好是以合法的方式,但必要时采取欺骗手段?
我通常将错误代码处理程序重新路由到控制器,以便我可以在渲染视图之前进行一些日志记录或其他操作。您也可以在这里使用它:
class UrlMappings {
static mappings = {
"/searchable/$action?"(controller: "errors", action: "urlMapping")
"/$controller/$action?/$id?" { }
"/"(view:"/index")
"403"(controller: "errors", action: "accessDenied")
"404"(controller: "errors", action: "notFound")
"405"(controller: "errors", action: "notAllowed")
"500"(view: '/error')
}
}
Run Code Online (Sandbox Code Playgroud)
其中 ErrorsController 看起来像这样:
class ErrorsController {
def accessDenied = {}
def notFound = {
log.debug "could not find $request.forwardURI"
}
def notAllowed = {}
def urlMapping = {
log.warn "unexpected call to URL-Mapped $request.forwardURI"
render view: 'notFound'
}
}
Run Code Online (Sandbox Code Playgroud)
并且您需要在 grails-app/errors 中创建 accessDenied.gsp、notFound.gsp 和 notAllowed.gsp
通过将“隐藏”控制器发送到其自定义映射,您可以记录对其的意外访问,但仍然呈现 404 页面以隐藏其存在。
| 归档时间: |
|
| 查看次数: |
1012 次 |
| 最近记录: |