【问题标题】:Grails Urlmapping 404 for group用于组的 Grails Urlmapping 404
【发布时间】:2020-05-26 09:49:40
【问题描述】:

我将我的 url 映射组织在带有组的 grails 中。

来自 UrlMappings 的示例:

class UrlMappings {

static mappings = {
    group "/rest", {
        "/" {
            controller = "rest"
            action = "index"
        }
        "/method1" {
            controller = "rest"
            action = "method1"
        }           
    }
    "/webservice/" {
        controller = "webservice"
        action = "index"
    }
}

我想要什么:当 URL 被称为 /rest/notexists 时,我想要这个路径的 404。但仅适用于 /rest 组,因此 404 应该属于组 rest。其他 404 由我的骨干路由器处理。

有什么想法吗?

【问题讨论】:

  • 您应该能够定义嵌套在 group '/rest' 内的“404( ... )”映射

标签: grails


【解决方案1】:

我在其余组的末尾用一个 catch all 解决了这个问题:

 "/**" {
            controller = "rest"
            action ="notFound"
 }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-15
    • 2014-10-06
    • 1970-01-01
    • 2019-10-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多