WebApplicationContext

本文介绍 Spring MVC 中 DispatcherServlet 使用的特殊 Bean 类型,如 HandlerMapping、HandlerAdapter 和 ViewResolver 等,这些 Bean 在处理请求和渲染视图中扮演关键角色。

Special Bean Types In the WebApplicationContext

The Spring DispatcherServlet uses special beans to process requests and render theappropriate views. These beans are part of Spring MVC. You can choose which specialbeans to use by simply configuring one or more of them in theWebApplicationContext.However, you don’t need to do that initially since Spring MVC maintains a list ofdefault beans to use if you don’t configure any. More on that in the next section. Firstsee the table below listing the special bean types the DispatcherServlet relies on.

Table 17.1. Special bean types in the WebApplicationContext

Bean typeExplanation

HandlerMapping

Maps incoming requests to handlers and a list of pre- and post-processors (handler interceptors) based on some criteria the details of which vary byHandlerMapping implementation. The most popular implementation supports annotated controllers but other implementations exists as well.

HandlerAdapter

Helps the DispatcherServlet to invoke a handler mapped to a request regardless of the handler is actually invoked. For example, invoking an annotated controller requires resolving various annotations. Thus the main purpose of a HandlerAdapter is to shield the DispatcherServlet from such details.

HandlerExceptionResolver

Maps exceptions to views also allowing for more complex exception handling code.

ViewResolver

Resolves logical String-based view names to actual View types.

LocaleResolver &LocaleContextResolver

Resolves the locale a client is using and possibly their time zone, in order to be able to offer internationalized views

ThemeResolver

Resolves themes your web application can use, for example, to offer personalized layouts

MultipartResolver

Parses multi-part requests for example to support processing file uploads from HTML forms.

FlashMapManager

Stores and retrieves the "input" and the "output" FlashMap that can be used to pass attributes from one request to another, usually across a redirect.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值