10.2. Configuring web.xml
Prev | 10. Spring MVC Integration | Next

## 10.2. Configuring web.xml

The first step to using Spring MVC is to configure the `DispatcherServlet` in `web.xml`. You typically do this once per web application.

The example below maps all requests that begin with `/spring/` to the DispatcherServlet. An `init-param` is used to provide the `contextConfigLocation`. This is the configuration file for the web 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/web-application-config.xml</param-value>
        </init-param>
    </servlet>

    <servlet-mapping>
        <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
        <url-pattern>/spring/*</url-pattern>
    </servlet-mapping>

Prev | Up | Next
10. Spring MVC Integration | Home | 10.3. Dispatching to flows