Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

spring mvc how to bypass DispatcherServlet for *.html files?

web.xml fragment

<!-- Handles all requests into the application -->
<servlet>
    <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/spring/app-config.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
    <url-pattern>/*</url-pattern>
</servlet-mapping>

It works fine but I'd like to NOT let the Dispatcher Servlet handle *.html requests. How do I I do that? Thanks.

like image 995
Bobo Avatar asked Dec 13 '10 19:12

Bobo


1 Answers

In Spring MVC 3.x there is the default servlet handler to take care of this problem.

just add this to the Spring XML config:

<mvc:default-servlet-handler/>
like image 104
Lari Hotari Avatar answered Sep 22 '22 18:09

Lari Hotari