diff --git a/src/asciidoc/images/mvc-context-hierarchy.png b/src/asciidoc/images/mvc-context-hierarchy.png new file mode 100644 index 00000000000..9c4a950caad Binary files /dev/null and b/src/asciidoc/images/mvc-context-hierarchy.png differ diff --git a/src/asciidoc/images/mvc-context-hierarchy.svg b/src/asciidoc/images/mvc-context-hierarchy.svg new file mode 100644 index 00000000000..52532ec2555 --- /dev/null +++ b/src/asciidoc/images/mvc-context-hierarchy.svg @@ -0,0 +1,612 @@ + + + +image/svg+xmlPage-1DispatcherServlet +Servlet WebApplicationContext +(containing controllers, view resolvers,and other web-related beans) +Controllers +ViewResolver +HandlerMapping +Root WebApplicationContext +(containing middle-tier services, datasources, etc.) +Services +Repositories +Delegates if no bean found + \ No newline at end of file diff --git a/src/asciidoc/images/mvc-contexts.gif b/src/asciidoc/images/mvc-contexts.gif deleted file mode 100644 index 15b28d0d39a..00000000000 Binary files a/src/asciidoc/images/mvc-contexts.gif and /dev/null differ diff --git a/src/asciidoc/images/mvc-root-context.png b/src/asciidoc/images/mvc-root-context.png new file mode 100644 index 00000000000..4e62f9215ae Binary files /dev/null and b/src/asciidoc/images/mvc-root-context.png differ diff --git a/src/asciidoc/images/mvc-root-context.svg b/src/asciidoc/images/mvc-root-context.svg new file mode 100644 index 00000000000..c29b270bc74 --- /dev/null +++ b/src/asciidoc/images/mvc-root-context.svg @@ -0,0 +1,328 @@ + + + +image/svg+xmlPage-1DispatcherServlet +Controllers +ViewResolver +HandlerMapping +Root WebApplicationContext +(containing all beans) +Services +Repositories +(with empty contextConfigLocation) +Servlet WebApplicationContext +Delegates + + \ No newline at end of file diff --git a/src/asciidoc/web-mvc.adoc b/src/asciidoc/web-mvc.adoc index 5f0a6fc4bf4..41b7d133a46 100644 --- a/src/asciidoc/web-mvc.adoc +++ b/src/asciidoc/web-mvc.adoc @@ -156,10 +156,9 @@ in the following diagram. The pattern-savvy reader will recognize that the `DispatcherServlet` is an expression of the "Front Controller" design pattern (this is a pattern that Spring Web MVC shares with many other leading web frameworks). +.The request processing workflow in Spring Web MVC (high level) image::images/mvc.png[width=400] -The request processing workflow in Spring Web MVC (high level) - The `DispatcherServlet` is an actual `Servlet` (it inherits from the `HttpServlet` base class), and as such is declared in the `web.xml` of your web application. You need to map requests that you want the `DispatcherServlet` to handle, by using a URL mapping in @@ -221,8 +220,8 @@ scoped. In the Web MVC framework, each `DispatcherServlet` has its own `WebApplicationContext`. These inherited beans can be overridden in the servlet-specific scope, and you can define new scope-specific beans local to a given Servlet instance. -.Context hierarchy in Spring Web MVC -image::images/mvc-contexts.gif[width=400] +.Typical context hierarchy in Spring Web MVC +image::images/mvc-context-hierarchy.png[width=400] Upon initialization of a `DispatcherServlet`, Spring MVC looks for a file named __[servlet-name]-servlet.xml__ in the `WEB-INF` directory of your web application and @@ -252,8 +251,13 @@ With the above Servlet configuration in place, you will need to have a file call Spring Web MVC-specific components (beans). You can change the exact location of this configuration file through a Servlet initialization parameter (see below for details). -It is also possible to have just one root context for single DispatcherServlet scenarios -by setting an empty contextConfigLocation servlet init parameter, as shown below: +It is also possible to have just one root context for single DispatcherServlet scenarios. + +.Single root context in Spring Web MVC +image::images/mvc-root-context.png[width=400] + +This can be configured by setting an empty contextConfigLocation servlet init parameter, +as shown below: [source,xml,indent=0] [subs="verbatim,quotes"]