提交 e9187daa 编写于 作者: R Rossen Stoyanchev

Improvements to DispatcherHandler chapter

上级 314f3fc5
......@@ -481,7 +481,8 @@ implement one of the framework contracts listed in the table below.
Spring WebFlux provides built-in implementations of these contracts but you can also
customize, extend, or replace them.
.Special bean types in the ApplicationContext
[[webflux-special-beans-table]]
[cols="1,2", options="header"]
|===
| Bean type| Explanation
......@@ -490,19 +491,43 @@ customize, extend, or replace them.
which vary by `HandlerMapping` implementation -- annotated controllers, simple
URL pattern mappings, etc.
The main `HandlerMapping` implementations are `RequestMappingHandlerMapping` based on
`@RequestMapping` annotated methods, `RouterFunctionMapping` based on functional
endpoint routes, and `SimpleUrlHandlerMapping` based on explicit registrations of URI
path patterns to handlers.
| HandlerAdapter
| Helps the `DispatcherHandler` to invoke a handler mapped to a request regardless of
| Help the `DispatcherHandler` to invoke a handler mapped to a request regardless of
how the handler is actually invoked. For example invoking an annotated controller
requires resolving various annotations. The main purpose of a `HandlerAdapter` is
to shield the `DispatcherHandler` from such details.
requires resolving annotations. The main purpose of a `HandlerAdapter` is to shield the
`DispatcherHandler` from such details.
| HandlerResultHandler
| Process the `HandlerResult` returned from a `HandlerAdapter`.
| Process the result from the handler invocation and finalize the response.
The built-in `HandlerResultHandler` implementations are `ResponseEntityResultHandler`
supporting `ResponseEntity` return values, `ResponseBodyResultHandler`
supporting `@ResponseBody` methods, `ServerResponseResultHandler`
supporting the `ServerResponse` returned from functional endpoints, and
`ViewResolutionResultHandler` supporting rendering with a view and a model.
|===
[[webflux-framework-config]]
=== Framework Config
[.small]#<<web.adoc#mvc-servlet-config,Same in Spring MVC>>#
The `DispatcherHandler` detects the special beans it needs in the `ApplicationContext`.
Applications can declare the special beans they wish to have. However most applications
will find a better starting point in the WebFlux Java config which provide a higher level
configuration API that in turn make the necessary bean declarations.
See <<webflux-config>> for more details.
[[webflux-dispatcher-handler-sequence]]
=== Processing sequence
=== Processing
[.small]#<<web.adoc#mvc-servlet-sequence,Same in Spring MVC>>#
The `DispatcherHandler` processes requests as follows:
......@@ -574,7 +599,7 @@ rendering).
[[webflux-ann-requestmapping]]
=== Mapping Requests
=== Request Mapping
[.small]#<<web.adoc#mvc-ann-requestmapping,Same in Spring MVC>>#
The `@RequestMapping` annotation is used to map requests to controllers methods. It has
......
......@@ -218,14 +218,14 @@ customize, extend, or replace them.
The mapping is based on some criteria the details of which vary by `HandlerMapping`
implementation.
The two main HandlerMapping implementations are `RequestMappingHandlerMapping` which
The two main `HandlerMapping` implementations are `RequestMappingHandlerMapping` which
supports `@RequestMapping` annotated methods and `SimpleUrlHandlerMapping` which
maintains explicit registrations of URI path patterns to handlers.
| HandlerAdapter
| Helps the `DispatcherServlet` to invoke a handler mapped to a request regardless of
| Help the `DispatcherServlet` to invoke a handler mapped to a request regardless of
how the handler is actually invoked. For example, invoking an annotated controller
requires resolving various annotations. The main purpose of a `HandlerAdapter` is
requires resolving annotations. The main purpose of a `HandlerAdapter` is
to shield the `DispatcherServlet` from such details.
| <<mvc-exceptionhandlers,HandlerExceptionResolver>>
......@@ -233,15 +233,15 @@ customize, extend, or replace them.
views, or other. See <<mvc-exceptionhandlers>>.
| <<mvc-viewresolver,ViewResolver>>
| Resolves logical String-based view names returned from a handler to an actual `View`
| Resolve logical String-based view names returned from a handler to an actual `View`
to render to the response with. See <<mvc-viewresolver>> and <<mvc-view>>.
| <<mvc-localeresolver,LocaleResolver>>, <<mvc-timezone,LocaleContextResolver>>
| Resolves the `Locale` a client is using and possibly their time zone, in order to be able
| Resolve the `Locale` a client is using and possibly their time zone, in order to be able
to offer internationalized views. See <<mvc-localeresolver>>.
| <<mvc-themeresolver,ThemeResolver>>
| Resolves themes your web application can use, for example, to offer personalized layouts.
| Resolve themes your web application can use, for example, to offer personalized layouts.
See <<mvc-themeresolver>>.
| <<mvc-multipart,MultipartResolver>>
......@@ -249,7 +249,7 @@ customize, extend, or replace them.
the help of some multipart parsing library. See <<mvc-multipart>>.
| <<mvc-flash-attributes,FlashMapManager>>
| Stores and retrieves the "input" and the "output" `FlashMap` that can be used to pass
| Store and retrieve the "input" and the "output" `FlashMap` that can be used to pass
attributes from one request to another, usually across a redirect.
See <<mvc-flash-attributes>>.
|===
......@@ -257,6 +257,8 @@ customize, extend, or replace them.
[[mvc-servlet-config]]
=== Framework Config
[.small]#<<web-reactive.adoc#webflux-framework-config,Same in Spring WebFlux>>#
For each type of special bean, the `DispatcherServlet` checks for the `WebApplicationContext` first.
If there are no matching bean types, it falls back on the default types listed in
https://github.com/spring-projects/spring-framework/blob/master/spring-webmvc/src/main/resources/org/springframework/web/servlet/DispatcherServlet.properties[DispatcherServlet.properties].
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册