首页 > 解决方案 > 用于组的 Grails Urlmapping 404

问题描述

我用组在 grails 中组织了我的 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

解决方案


我在其余组的末尾全部解决了这个问题:

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

推荐阅读