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

Bobo picture Bobo · Dec 13, 2010 · Viewed 21.9k times · Source

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.

Answer

Lari Hotari picture Lari Hotari · May 7, 2012

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/>