Skip to content

Commit 80cb0c4

Browse files
sdeleuzerstoyanchev
authored andcommitted
Include more guidance about DispatcherServlet context
Also update <mvc:annotation-driven /> comment in XSD. Issue: SPR-11703
1 parent 5c4804f commit 80cb0c4

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

spring-webmvc/src/main/resources/org/springframework/web/servlet/config/spring-mvc-4.0.xsd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<xsd:annotation>
1616
<xsd:documentation source="java:org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"><![CDATA[
1717
Configures the annotation-driven Spring MVC Controller programming model.
18-
Note that, with Spring 3.0, this tag works in Servlet MVC only!
18+
Note that this tag works in Web MVC only, not in Portlet MVC!
1919
2020
See org.springframework.web.servlet.config.annotation.EnableWebMvc Javadoc for
2121
information on code-based alternatives to enabling annotation-driven Spring MVC

src/asciidoc/index.adoc

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28200,6 +28200,37 @@ With the above Servlet configuration in place, you will need to have a file call
2820028200
Spring Web MVC-specific components (beans). You can change the exact location of this
2820128201
configuration 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+
2820328234
The `WebApplicationContext` is an extension of the plain `ApplicationContext` that has
2820428235
some 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

Comments
 (0)