我可以在拦截器执行之前触发Grails url映射吗?

时间:2016-05-19 20:31:00

标签: 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 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的网址映射发生吗?

0 个答案:

没有答案