diff --git a/src/docs/asciidoc/web/web-cors.adoc b/src/docs/asciidoc/web/web-cors.adoc index eb5042d404b..8dab5092864 100644 --- a/src/docs/asciidoc/web/web-cors.adoc +++ b/src/docs/asciidoc/web/web-cors.adoc @@ -1,5 +1,5 @@ [[cors]] -= Spring Web MVC CORS Support += Spring MVC CORS Support == Introduction diff --git a/src/docs/asciidoc/web/web-mvc.adoc b/src/docs/asciidoc/web/web-mvc.adoc index ef193b7734b..b7c8c4951c0 100644 --- a/src/docs/asciidoc/web/web-mvc.adoc +++ b/src/docs/asciidoc/web/web-mvc.adoc @@ -3,14 +3,15 @@ :doc-spring-security: {doc-root}/spring-security/site/docs/current/reference [[mvc-introduction]] -== Introduction to Spring Web MVC +== Introduction Spring Web MVC is the Servlet-based, web framework included in the Spring Framework. Its name is based on the name of the module, "spring-webmvc", but most people call it simply Spring MVC. The Spring Framework also includes the reactive, <> -web framework that runs on on Servlet containers via Servlet 3.1 non-blocking I/O -as well as on other non-blocking runtimes such as Netty and Undertow. +web framework that does not depend on the Servlet API but can run on Servlet containers +(via Servlet 3.1 non-blocking I/O) or on other non-blocking runtimes such as +Netty or Undertow. @@ -25,18 +26,18 @@ and exception handling facilities. The `DispatcherServlet` provides the shared algorithm for processing requests while actual work is performed by configurable, delegate components. This model is very flexible and it can be used with just about any workflow, with the installation of the -appropriate delegate components -(see <>). +appropriate delegate components. The `DispatcherServlet` uses Spring configuration to discover the delegate components -it needs to perform handler mapping, view resolution, and much more. As an actual -`Servlet` it needs to be declared and mapped according to the Servlet specification. -This can be done through code configuration or in`web.xml`. +it needs to perform handler mapping, view resolution, and much more +(see <>). As an actual +`Servlet` it also needs to be declared and mapped according to the Servlet specification. +This can be done through code-based configuration or in `web.xml`. -Below is an example of code-based configuration where `WebApplicationInitializer` is an -interface provided by Spring MVC that ensures this Java-based configuration is -auto-detected by the Servlet container (see -<> for more details): +Below is an example of code-based configuration. Note that `WebApplicationInitializer` is +an interface provided by Spring MVC that ensures it is auto-detected by the Servlet +container (see <> +for more details): [source,java,indent=0] [subs="verbatim,quotes"] @@ -65,8 +66,8 @@ public class MyWebApplicationInitializer implements WebApplicationInitializer { In addition to using the ServletContext API directly as shown above, you can also extend the convenient base class `AbstractAnnotationConfigDispatcherServletInitializer` and -override specific methods to customize it (an example is shown later under -<>). +override specific methods to customize it. An example of that is shown in the next +section <>. Below is the `web.xml` equivalent of the above code-based example: @@ -106,20 +107,6 @@ Below is the `web.xml` equivalent of the above code-based example: [[mvc-servlet-context-hierarchy]] === WebApplicationContext Hierarchy -For many applications, a single `WebApplicationContext` is simple and sufficient. -It is also possible to set up a context hierarchy where one root `WebApplicationContext` -is shared across multiple `DispatcherServlet` (or other `Servlet`) instances each with -its own `WebApplicationContext` configuration -(see <> -for more details). - -The root `WebApplicationContext` contains infrastructure beans (e.g. data repositories, -business services) that need to be shared across multiple Servlet instances. These beans -are effectively inherited and can be overridden (re-declared) in the Servlet-specific -context, which also contains beans local to the given `Servlet`. - -image::images/mvc-context-hierarchy.png[] - [NOTE] ==== `WebApplicationContext` is an extension of the plain `ApplicationContext` that has @@ -131,7 +118,22 @@ a link to the `ServletContext`). `WebApplicationContext` is bound to the always look up the `WebApplicationContext` if you need access to it. ==== -Below is an example of configuration that sets up a `WebApplicationContext` hierarchy: +For many applications, a single `WebApplicationContext` is simple and sufficient. +However it is also possible to set up a context hierarchy where one root `WebApplicationContext` +is shared across multiple `DispatcherServlet` instances, or other `Servlet`, each with +its own `WebApplicationContext` configuration -- +see <> +for more on the context hierarchy feature of Spring. + +The root `WebApplicationContext` should contain infrastructure beans, e.g. data repositories or +business services, that need to be shared across multiple `Servlet` instances. These beans +are effectively inherited and could be overridden, or rather re-declared, in the Servlet-specific +`WebApplicationContext` which for the most part contains beans local to the given `Servlet` +as shown in the below diagram: + +image::images/mvc-context-hierarchy.png[] + +Below is example configuration of how to set up a `WebApplicationContext` hierarchy: [source,java,indent=0] [subs="verbatim,quotes"] @@ -155,7 +157,7 @@ Below is an example of configuration that sets up a `WebApplicationContext` hier } ---- -Below is the `web.xml` equivalent: +And the `web.xml` equivalent: [source,xml,indent=0] [subs="verbatim,quotes"] @@ -3624,7 +3626,7 @@ request with a simple request parameter. [[mvc-multipart]] -== Spring's multipart (file upload) support +== Multipart (file upload) support diff --git a/src/docs/asciidoc/web/web-view.adoc b/src/docs/asciidoc/web/web-view.adoc index 520c718805d..d7c24893d5d 100644 --- a/src/docs/asciidoc/web/web-view.adoc +++ b/src/docs/asciidoc/web/web-view.adoc @@ -1,5 +1,5 @@ [[view]] -= Spring Web MVC View Technologies += Spring MVC View Technologies [[view-introduction]]