Grails 3.0.1在这里。我正在寻找完成特定的 URL/控制器结构。我的应用程序部署在根上下文 ( /
),这意味着它在本地运行为http://localhost:8080
,而非本地运行为http://someserver.example.org
。
我希望所有内容都/app/*
经过身份验证并被视为“核心应用程序”的一部分(需要登录)。该 URL 之外的任何内容都被视为公共网站的一部分(未经身份验证)。但是,我希望/app/
自己只是一个占位符;我不希望它成为 Grails 控制器。因此:
http://localhost:8080/app
可以配置 (UrlMappings
?) 以显示登录页面http://localhost:8080/app/<controller>/<action>
遵循典型的 Grails 控制器/动作套装,并会调用正确的控制器动作
因此http://localhost:8080/app/order/create
将通过身份验证,如果登录,则调用该OrderController#create
操作,该操作可能会呈现一个createOrder.gsp
.
我想知道 Grails 3.x 方法是什么:
- 允许
/app/
存在,但不是作为控制器(就像我说的,也许只是重定向/映射到登录页面) - 允许下面的任何东西
/app/
遵循控制器/动作范例
关于如何实施的想法?
更新
class UrlMappings {
static mappings = {
"/$controller/$action?/$id?(.$format)?"{
constraints {
// apply constraints here
}
}
"/app/$controller/$action?/$id?" {
???
}
"/"(view:"/index")
"500"(view:'/error')
"404"(view:'/notFound')
}
}