我有一个Grails 3.1.3应用程序,其中包含以下设置:
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}"
}
...
}
导航到应用的上下文根(即http://localhost:8080/app-context-root/)时,会产生以下结果:
request.requestURI: /app-context-root/
Reached index action
除了在UrlMappings.groovy中使用重定向之外,我可以在我的拦截器收到请求URI之前将/
到/app-context-root/index/index
的网址映射发生吗?