@@ -28200,6 +28200,37 @@ With the above Servlet configuration in place, you will need to have a file call
2820028200Spring Web MVC-specific components (beans). You can change the exact location of this
2820128201configuration file through a Servlet initialization parameter (see below for details).
2820228202
28203+ It is also possible to have just one root context for single DispatcherServlet scenarios
28204+ by setting an empty contextConfigLocation servlet init parameter, as shown below:
28205+
28206+ [source,xml,indent=0]
28207+ [subs="verbatim,quotes"]
28208+ ----
28209+ <web-app>
28210+ <context-param>
28211+ <param-name>contextConfigLocation</param-name>
28212+ <param-value>/WEB-INF/root-context.xml</param-value>
28213+ </context-param>
28214+ <servlet>
28215+ <servlet-name>dispatcher</servlet-name>
28216+ <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
28217+ <init-param>
28218+ <param-name>contextConfigLocation</param-name>
28219+ <param-value></param-value>
28220+ </init-param>
28221+ <load-on-startup>1</load-on-startup>
28222+ </servlet>
28223+ <servlet-mapping>
28224+ <servlet-name>dispatcher</servlet-name>
28225+ <url-pattern>/*</url-pattern>
28226+ </servlet-mapping>
28227+ <listener>
28228+ <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
28229+ </listener>
28230+ </web-app>
28231+ ----
28232+
28233+
2820328234The `WebApplicationContext` is an extension of the plain `ApplicationContext` that has
2820428235some extra features necessary for web applications. It differs from a normal
2820528236`ApplicationContext` in that it is capable of resolving themes (see
@@ -31888,7 +31919,9 @@ To enable MVC Java config add the annotation `@EnableWebMvc` to one of your
3188831919 }
3188931920----
3189031921
31891- To achieve the same in XML use the `mvc:annotation-driven` element:
31922+ To achieve the same in XML use the `mvc:annotation-driven` element in your
31923+ DispatcherServlet context (or in your root context if you have no DispatcherServlet
31924+ context defined):
3189231925
3189331926[source,xml,indent=0]
3189431927[subs="verbatim,quotes"]
0 commit comments