5

Searchableプラグインのデフォルトの検索ページ( http:// localhost / searchable / )を無効にしようとしていますが、その方法が見つかりません。できれば合法的な方法でこれを行う方法を知っている人はいますが、必要に応じてトリックに頼っていますか?

4

1 に答える 1

4

私は通常、エラーコードハンドラーをコントローラーに再ルーティングして、ビューをレンダリングする前にロギングなどを実行できるようにします。ここでも使用できます:

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は次のようになります。

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を作成する必要があります

'hidden'コントローラーをカスタムマッピングに送信することで、予期しないアクセスをログに記録できますが、404ページをレンダリングしてその存在を非表示にします。

于 2010-07-03T03:52:56.613 に答える