我可以在执行拦截器之前触发Grails url映射吗?
我有一个Grails 3.1.3应用程序,具有以下设置:我可以在执行拦截器之前触发Grails url映射吗?,grails,groovy,url-mapping,urlmappings.groovy,Grails,Groovy,Url Mapping,Urlmappings.groovy,我有一个Grails 3.1.3应用程序,具有以下设置: class UrlMappings { static mappings = { "/error"(controller: 'error', action: 'error') "/$controller/$action?/$id?"() "/"(controller: "index", action: "index") } } class
class UrlMappings {
static mappings = {
"/error"(controller: 'error', action: 'error')
"/$controller/$action?/$id?"()
"/"(controller: "index", action: "index")
}
}
class IndexController {
static allowedMethods = [index:'GET']
def index() {
println "Reached index action"
...
}
}
class FormInterceptor implements grails.artefact.Interceptor {
int order = HIGHEST_PRECEDENCE + 100
FormInterceptor() {
matchAll()
}
boolean before() {
println "request.requestURI: ${request.requestURI}"
}
...
}
导航到应用程序的上下文根目录(即)时,会产生以下输出结果:
request.requestURI: /app-context-root/
Reached index action
除了在UrlMappings.groovy中使用重定向之外,我可以在拦截器接收请求URI之前将url从
/
映射到/app context root/index/index
?我也有同样的怀疑。