grails 默认配置的拦截器

grails 1.2之后参与web.xml:
def doWithWebDescriptor = { webXml ->
def mappingElement = webXml.'servlet-mapping'
def lastMapping = mappingElement[mappingElement.size()-1]
lastMapping + {
'servlet-mapping' {
'servlet-name'("grails")
'url-pattern'("*.dispatch")
}
}
}



所有的.dispatch结尾的请求会有GrailsDispatcherServlet来处理
拦截路径:/grails/controller/action.dispatch
  <!-- Grails dispatcher servlet -->
    <servlet>
        <servlet-name>grails</servlet-name>
        <servlet-class>org.codehaus.groovy.grails.web.servlet.GrailsDispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <!-- The Groovy Server Pages servlet -->
    <servlet>
        <servlet-name>gsp</servlet-name>
        <servlet-class>org.codehaus.groovy.grails.web.pages.GroovyPagesServlet</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>gsp</servlet-name>
        <url-pattern>*.gsp</url-pattern>
    </servlet-mapping>

[color=brown]GroovyPagesServlet用来拦截gsp文件
路径顺序:grails-app/views/controller/action.gsp [/color
]

你可能感兴趣的:(xml,Web,servlet,grails,groovy)