组的Grails Urlmapping 404

问题描述 投票:0回答:1

我以组的形式组织了URL映射。

来自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由我的骨干路由器处理。

有什么想法吗?

grails
1个回答
0
投票

您可以直接在分组中定义它:

static mappings = {
    group "/rest", {
        "/" {
            controller = "rest"
            action = "index"
        }
        "/method1" {
            controller = "rest"
            action = "method1"
        }   
        "404"(view: '/notexists')
    }
    // ...
}
© www.soinside.com 2019 - 2024. All rights reserved.