禁用 grails Searchable 插件默认搜索页面? [英] Disable grails Searchable plugin default search page?
问题描述
我正在尝试禁用 Searchable 插件默认搜索页面 (http://localhost/searchable/),但还没有找到方法来做到这一点.任何人都知道如何做到这一点,最好以合法的方式,但在必要时诉诸诡计?
I'm trying to disable the Searchable plugin default search page (http://localhost/searchable/), but haven't found a way to do it. Anyone know how this can be done, preferably in a legit way, but resorting to trickery if necessary?
推荐答案
我通常将错误代码处理程序重新路由到控制器,这样我就可以在渲染视图之前进行一些日志记录或其他操作.你也可以在这里使用它:
I usually re-route error code handlers to a controller so I can do some logging or whatever before rendering the view. You can use that here also:
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')
}
}
其中 ErrorsController 看起来像这样:
where ErrorsController looks something like this:
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'
}
}
并且您需要在 grails-app/errors 中创建 accessDenied.gsp、notFound.gsp 和 notAllowed.gsp
and you'll need to create accessDenied.gsp, notFound.gsp, and notAllowed.gsp in grails-app/errors
通过将隐藏"控制器发送到其自定义映射,您可以记录对其的意外访问,但仍会渲染 404 页面以隐藏其存在.
By sending a 'hidden' controller to its custom mapping you can log unexpected access to it, but still render the 404 page to hide its existence.
这篇关于禁用 grails Searchable 插件默认搜索页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!